This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Shortcode in Search results not working

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #28981
    yonahs61332yonahs61332
    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 MarcinkoErnest 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.

    #29334
    yonahs61332yonahs61332
    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

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.