Jump to content
Sign in to follow this  
Danny

Search results hook working but displaying on all pages/posts ?

Recommended Posts

Danny

Hi, I've added a hook to functions.php using the following code: // Search Results // add_action('pagelines_before_theloop','searchresults'); function searchresults(){?> <?php is_search(); ?> Showing results for "<?php the_search_query() ?>". Here are the results: <?php } Now this works but for some reason is displaying on all posts and pages, which of course I don't want, so what do I need to change on the code to display this to only search results? I did try adding this <?php if ( is_search(); ?> but results in an T String error? Thanks Danny


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
kastelic

Just tested this to work:

	function searchresults(){
	if (is_search()) :
	?>
	Showing results for "<?php the_search_query() ?>". Here are the
	results:
	<?php
	endif;
	}
	
	

Share this post


Link to post
Share on other sites
Danny

Thanks Kastelic, that worked a treat. I see now what I was actually doing to get the error. Thank again.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×