Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 17th Mar 2015, 01:04 PM   #1
HyperActive Warrior
Registered Member
War Room Member
 
IMPromocoder's Avatar
 
Join Date: 2012
Posts: 301
Thanks: 34
Thanked 44 Times in 34 Posts
Default
Customizing WP site search results
Share on: 
fb share twitter share gplus share more share

Hi all,
Is there a simple method/plugin to customize the search results made on my site?
For example, instead of returning an empty page or no results found, return a custom message or call to action?

Thanks,


Last edited on 17th Mar 2015 at 01:05 PM. Reason: Typo
IMPromocoder is offline  
Unread 17th Mar 2015, 01:36 PM   #2
Senior Warrior Member
War Room Member
 
Join Date: 2009
Posts: 1,057
Thanks: 124
Thanked 198 Times in 147 Posts
Default
Re: Customizing WP site search results
Share on: 
fb share twitter share gplus share more share

You need to find where the error message is generated in your theme and edit it (I remember in Atahualpa it is in index.php) or just add/edit the error template:
Creating an Error 404 Page « WordPress Codex

rhinocl is offline  
Unread 18th Mar 2015, 09:19 PM   #3
HyperActive Warrior
War Room Member
 
emptee's Avatar
 
Join Date: 2014
Location: New Zealand
Posts: 210
Thanks: 25
Thanked 81 Times in 71 Posts
Default
Re: Customizing WP site search results
Share on: 
fb share twitter share gplus share more share

Hi mate,

Depends on the theme - I'll show you how you could do it in twentythirteen and you can (hopefully) apply it easily enough to your theme

First things first - check out search.php in the theme directory (if it uses it - otherwise look around for some string that is "near" the search results, some markup with an id tag is normally the best target...)

Anyway - looking at search.php, there's a pattern:

Code:
<?php if ( have_posts() ) : ?>

//stuff to show search results..

<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?> // <-- this is interesting....
<?php endif; ?>
Cool - so this tells us that what we're looking for is in the content none template... which leads us to 'content-none.php'

Which looks something like this..

Code:
<header class="page-header">
	<h1 class="page-title"><?php _e( 'Nothing Found', 'twentythirteen' ); ?></h1>
</header>

<div class="page-content">
<?php if ( is_home() && current_user_can( 'publish_posts' ) ) : ?>

<p><?php printf( __( 'Ready to publish your first post? <a href="%1">Get started here</a>.', 'twentythirteen' ), admin_url( 'post-new.php' ) ); ?></p>

<?php elseif ( is_search() ) : ?>

<p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with different keywords.', 'twentythirteen' ); ?></p>
<?php get_search_form(); ?>

// ^^^^ This is where you could do whatever you like! I'd recommend something along the lines of... <?php do_shortcode("some form plugin shortcode"); ?>
// that way you can change the form/optin/picture of a cat easily from within WP

<?php else : ?>

<p><?php _e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', 'twentythirteen' ); ?></p>
<?php get_search_form(); ?>

<?php endif; ?>
You could also change the get_template_part instead - but, IMO, changing the content-none is cleaner

Cheers,
Michael

Originally Posted by IMPromocoder View Post

Hi all,
Is there a simple method/plugin to customize the search results made on my site?
For example, instead of returning an empty page or no results found, return a custom message or call to action?

Thanks,

emptee is offline  
The Following User Says Thank You to emptee For This Useful Post:
Unread 25th Mar 2015, 10:38 AM   #4
Just Follow Your Dreams
 
voldamort's Avatar
 
Join Date: 2014
Location: earth
Posts: 101
Thanks: 25
Thanked 30 Times in 29 Posts
Default
Re: Customizing WP site search results
Share on: 
fb share twitter share gplus share more share

you need to go into root into the theme files .... do what rhinocl is telling ... if you are using sublime editor just search all the files with the text and replace with your text ....
voldamort is offline  
Closed Thread


Bookmarks

Tags
customizing, results, search, site


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 05:14 AM.