Shortcode in Search results not working

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Shortcode in Search results not working

This topic contains 2 replies, has 2 voices, and was last updated by yonahs61332 yonahs61332 3 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #28981
    yonahs61332
    yonahs61332
    Participant

    I understand that the [] are used as conditional tags, so how am I supposed to enter a shortcode?

    I have tried [shotcodeText] one and it just displays the ShortCode as text

    I am talking about the Advanced Fields section on Advanced Options->Content

    I have tried the “Execute them” and “Remove Them” options

    #29000
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    In short, you cannot enter shortcodes there. Most shortcodes are registered in a loop or single content sections, and may require additional parameters to work.

    The only way you should try that, is programatically adding the shortcode to the content via the asp_results hook.

    Something like this:

    add_filter( 'asp_results', 'asp_add_custom_shortcode', 10, 1 );
    function asp_add_custom_shortcode( $results ) {
    	foreach ($results as $k=>&$r) {
    		// Enter the shortcode into the quotes section
    	  	$r->content = do_shortcode('[my_shortoce_here]') . $r->content;
    	}
    
    	return $results;
    }

    Still, this may not work, as shortcodes should be optimally added inside the post editor directly, otherwise they might not process correctly.

    Best,
    Ernest Marcinko

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


    #29334
    yonahs61332
    yonahs61332
    Participant

    Ok, I have solved my problem, I have customized the Horizontal template and the shortcode HTML is there, but there is still a problem and the solution seems simple enough, but I need some help implementing it:
    https://support.yotpo.com/en/article/loading-yotpo-with-ajax

    How can I run this javascript widget at the right time without your plugin?

    Thanks

    • This reply was modified 3 years, 7 months ago by yonahs61332 yonahs61332.
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.