| | #1 |
| HyperActive Warrior Registered Member War Room Member Join Date: 2012
Posts: 301
Thanks: 34
Thanked 44 Times in 34 Posts
|
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 | |
| |
| | #2 |
| Senior Warrior Member War Room Member Join Date: 2009
Posts: 1,057
Thanks: 124
Thanked 198 Times in 147 Posts
|
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 |
| | |
| |
| | #3 |
| HyperActive Warrior War Room Member Join Date: 2014 Location: New Zealand
Posts: 210
Thanks: 25
Thanked 81 Times in 71 Posts
|
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; ?> 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’t find what you’re looking for. Perhaps searching can help.', 'twentythirteen' ); ?></p>
<?php get_search_form(); ?>
<?php endif; ?> ![]() Cheers, Michael |
| | |
| |
| The Following User Says Thank You to emptee For This Useful Post: |
| | #4 |
| Just Follow Your Dreams Join Date: 2014 Location: earth
Posts: 101
Thanks: 25
Thanked 30 Times in 29 Posts
|
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 ....
|
| |
|
| Bookmarks |
| Tags |
| customizing, results, search, site |
| |