Activate Shortcodes in your Search Results

As explained here, Profi Search Form comes along with some unique hooks and filters, which enables you to extend the plugin without altering the code itself. On this page, we explain you, how you can use one of these filters in order to activate shortcodes, which you might place inside of the search results.

To give you an example. Lets say, you have a gallery plugin, which creates a gallery out of the images attached to a blogpost. You want to show this gallery in the result list.

So, your template might look something like this

<h1><a href="#the_permalink#">#the_title#</a></h1>
<div>[ gallery id="#the_ID#"]


As you can see, usually the shortcode won’t be executed by the Plugin. But, we have a filter hook called ‘sf-results-single-result’. This enables you to create a function, which executes the shortcode for you.

	add_filter( 'sf-results-single-result', 'psf_shortcode' );
	function psf_shortcode( $element ){
		return do_shortcode( $element );

If you place this function in your themes functions.php the shortcodes will be executed.

Use our search to find more help:


© 2014, websupporter | Credits

This is a demo store for testing purposes — no orders shall be fulfilled.