Reply To: RPS Plugin Shortcode Appear on Results Page

Home Forums Product Support Forums Ajax Search Pro for WordPress Support RPS Plugin Shortcode Appear on Results Page Reply To: RPS Plugin Shortcode Appear on Results Page

#12143

sschoch
Participant

Hi, Ernest:

The problem I described above wasn't accurate. I fixed it by turning on the option to have Ajax Pro replace the theme's search. So the search results look fine now.

BUT, I do have another problem. You might remember that you gave me the code pasted in below to fix the issue where links to our online help system in the search results were going to post names, but the pages on the online help system use page IDs. This works great for links that appear in the live search results, but not when I click links on the Search Results page. Those still try to go to a post name.

Is there a modification you can make to the code below to make it work for links on the Search Results page also or is there another solution?

add_filter(‘asp_results’, ‘asp_try_fixing_permalinks’, 10, 1);
add_filter(‘asp_regular_search_result’, ‘asp_try_fixing_permalinks’, 10, 1);

function asp_try_fixing_permalinks( $results ) {
  
  $url = &#8216;Help site path&#8217;;  // Change this to the help site path, like <a href="http://site.com" rel="nofollow">http://site.com</a>

  foreach ($results as $k =&amp;gt; &amp;amp;$r) {
    if ( isset($r-&amp;gt;asp_guid) ) {
      if ( strpos($r-&amp;gt;asp_guid, $url) !== false ) {
        $r-&amp;gt;asp_guid = $url . &#8216;?page_id=&#8217; . $r-&amp;gt;ID;  
      }
    } else {
      if ( strpos($r-&amp;gt;link, $url) !== false ) {
        $r-&amp;gt;link = $url . &#8216;?page_id=&#8217; . $r-&amp;gt;id;
      }
    }
  }

  return $results;
}