Skipping characters for summarytext

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Skipping characters for summarytext

This topic contains 4 replies, has 2 voices, and was last updated by maarten19855 maarten19855 6 years, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6921
    maarten19855
    maarten19855
    Participant

    Hi,

    The first X characters on every post are always the same. So for the summary shown in the search results for ajax search pro I would like to skip X characters by default. How can I set a default characters to skip before taking the content shown in the results? Or perhaps add some code at the beginning of the paragraph I want to show per page?

    Both can be seen when you use my main ajax search box on the website provided.

    Thanks in advance!

    Regards,

    • This topic was modified 6 years, 7 months ago by maarten19855 maarten19855.
    #6925
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Only by using a custom code, but luckily you don’t have to edit any of the plugin files, so this should be update-proof as well.

    Try putting this code to your currently active theme folder, into the functions.php file:

    
    add_filter( 'asp_result_content_after_prostproc', 'asp_cut_from_content', 1, 1 );
    
    function asp_cut_from_content( $content ) {
      // Change this to the number of characters you want to cut
      $charaters_to_cut = 50;
      
      return substr($content, $charaters_to_cut);
    
    }
    

    Change the $characters_to_cut variable to the number of characters you want to remove from the beginning.

    Best,
    Ernest Marcinko

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


    #6926
    maarten19855
    maarten19855
    Participant

    Thanks for the reply and the code Ernest. It seems to work fine with just 50 characters to skip. But when I choose to skip the first 600 characters it doesn’t show the description. The only thing showing is the title of the page. Is there a max characters to which the plugin uses the description. I need it to skip the first 600 characters.

    #6927
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Yes, you probably need to increase the description length. By default it’s 130 characters. You can change that on the Layout Options -> Results Layout panel with the Description (content) length option. I recommed trying like 730 at first, and perhaps increasing it until you start seeing the description.

    Best,
    Ernest Marcinko

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


    #6928
    maarten19855
    maarten19855
    Participant

    Ah, why didn’t I think of that :). Thanks, it works perfectly now!

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

You must be logged in to reply to this topic.