Shortcode in results box

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 1 year, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31178
    pmcnealy97
    pmcnealy97
    Participant

    Is there a way to add short code to the results box? I want to add a shortcode to add a button. However, it seems the short codes aren’t working. I’m sure it’s just my lack of knowledge, but I want to be sure before I go crazy trying to figure it out. Thanks for the help.

    #31184
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    It is not possible via the options, but programmatically via the asp_results plugin hook.

    For example, if you would want to execute the shortcode ‘[my_shortcode]’ shortcode and append to the result content, this code does it:

    add_filter( 'asp_results', 'asp_custom_shortcode_results', 10, 1 );
    function asp_custom_shortcode_results( $results ) {
    	
    	// Parse through each result item
    	foreach ($results as $k=>&$r) {
    		if ( isset($r->post_type) ) {
    			$r->content .= do_shortcode('[my_shortcode]');
    		}
    	}
    
    	return $results;
    }
    Best,
    Ernest Marcinko

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


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

You must be logged in to reply to this topic.