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

This topic contains 7 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 7 years ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #12128
    sschoch
    sschoch
    Participant

    Hi, Ernest:

    Some of the pages in our system contain only a shortcode (via the RPS Include plugin) to include content from another page. When Ajax Search Pro returns these pages in a search, it shows the shortcode as the excerpt (see attached). I have tried enabling the Advanced Options -> What to do with shortcodes in results content? > Execute them option, but it doesn’t change anything. Clicking the page title goes to the page, which activates the shortcode and displays the page content, so no problem there.

    Is there a way to display an excerpt from the included text? If not, is there a way to hide the excerpt when it contains only a shortcode?

    Thank you, Stephanie Schoch

    Attachments:
    You must be logged in to view attached files.
    #12136
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Stephanie,

    I’m afraid the issue is not related to ajax search pro in this case. The plugin only passes on the post objects to the results handler, the displaying is done via the theme, I’m guessing via the the_excerpt() call, at least that it what most themes usually do.

    I believe it is possible however to execute shortcodes in excerpts: https://goo.gl/3Aus3q

    You might need to ask the theme developer on how exactly change the contents there 🙂

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12143
    sschoch
    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 = 'Help site path';  // Change this to the help site path, like http://site.com
    
      foreach ($results as $k => &$r) {
        if ( isset($r->asp_guid) ) {
          if ( strpos($r->asp_guid, $url) !== false ) {
            $r->asp_guid = $url . '?page_id=' . $r->ID;  
          }
        } else {
          if ( strpos($r->link, $url) !== false ) {
            $r->link = $url . '?page_id=' . $r->id;
          }
        }
      }
    
      return $results;
    }
    
    #12147
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    In that case there might have been something else overriding the results (or perhaps modifying them in some way), I’m guessing by turning on the override option on the search fixes that as it passes the objects correctly. Anyways, it is fixed and that’s great.

    Changing the links on the results page very much depends on how the theme outputs them, and unfortunately there is a good chance that they might not be changeable with the standard known methods, I’m not sure to be honest.
    I’ve taken a sample solution from the wordpress documentation, which should work in most cases for changing the permalinks on the results page:

    Again, this very much depends on the theme itself, but it’s worth a try.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12149
    sschoch
    sschoch
    Participant

    Hi, Ernest:

    I added the code to the theme’s functions.php file. All of the links to the help site go to a page with a page ID of -10. Any ideas?

    https://stage-help.netbase.com/cb/help/ic2/?page_id=-10

    Thanks, Steph

    #12154
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Steph,

    Interesting. How about this modification:

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12160
    sschoch
    sschoch
    Participant

    Hi, Ernest:

    That worked, thank you.

    Now, one more thing. When I include courses and lessons in the search and click the links in the results (either the drop-down list under the search box or the results page), I get a “Page Not Found” error. These all reside on the same site with the Ajax search box. I’ve included a screenshot of the post types added on the General Options -> Sources tab. Am I forgetting to do something?

    Attachments:
    You must be logged in to view attached files.
    #12170
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Assuming that both the drop-down and the results page results URLs are overwritten, I’m guessing that the $url variable is most likely set incorrectly, or maybe the page_id=.. solution doesn’t work for them. Maybe the ID solution should apply to ‘page’ post types only? In that case try changing both of the codes to this:

    (don’t forget to change the $url variables in both case)

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.