Jump to content

Wordpress Search Tweaks


Roger S

Recommended Posts

I have been trying to get the search function to do what I want it to do. (WP and NextGen Gallery)The site that I’m working on is a stock photography site, without blog posts. I want the search to return results based on keywords. I have accomplished that. What I’m having issues with is I would like the gallery results returned to the page (which I have also accomplished) but when there are no results, a message about no results and the search box. Currently, it returns the message and search box, whether or not there are results.

 

I have to say that what I know about PHP will fit on the head of a pin but here is the code so far (a mixture of codes found through forums). I’m sure this is quite simple, but then, so am I!

<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentyten' ), '<span>' . get_search_query() . '</span>' ); ?></h1>

<?php if (ngg_images_results() ) : ?>
<?php echo ngg_images_results();?>
<?php else : ?>
       <div id="post-0" class="post no-results not-found">
	<h2 class="entry-title"><?php _e( 'Nothing Found', 'twentyten' ); ?></h2>
		<div class="entry-content">
		<p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'twentyten' ); ?></p>
		<?php get_search_form(); ?>
		</div><!-- .entry-content -->
</div><!-- #post-0 -->
<?php endif; ?>

 

And yes, I have been to the WP Forums to no avail-so thanks for your help!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.