Hi, I’m wondering how I change the page that displays when no results are found when doing a search. I would like to display this page http://wildernesstraveller.com/error404/ which is my standard 404 page.
Many thanks
James
Hi, I’m wondering how I change the page that displays when no results are found when doing a search. I would like to display this page http://wildernesstraveller.com/error404/ which is my standard 404 page.
Many thanks
James
Also on my blog posts do you know how I can move the meta data below the title (in the same white box)?
Thanks
James
Hi There,
Thank you for writing in, please navigate to Pro > Overview and install the Custom 404 extension.
Then on Pro > Custom 404 set your http://wildernesstraveller.com/error404/ page as your 404 page.
Regarding the blog posts, regretfully your posts page template is modified and we can not provide support for customization.
Cheers!
Hi, I have tried to use that plugin but I get a fatal error when I try to activate it:
Parse error: syntax error, unexpected ‘[’ in /var/sites/w/wildernesstraveller.com/public_html/wp-content/plugins/tco-custom-404/tco-custom-404.php on line 107
No problem regarding the page template.
Thanks
James
Looks like it was my PHP version that needed updating. I got the plugin working but it still shows the standard page when I do a search that yields no results.
Hi there,
Please add this code to your child theme’s functions.php
add_action('init', 'redirect_if_search_is_empty', 999999999);
function redirect_if_search_is_empty () {
global $wp_query;
if ( $wp_query->is_search() && $wp_query->found_posts <=0 ) {
wp_redirect( 'http://wildernesstraveller.com/error404/' );
exit;
}
}
This should redirect your empty search page to your 404 page.
Thanks!
Hi,
Please let us know how it goes.
Thanks
Hi, I have tried adding that code but it hasn’t made any difference unfortunately.
Hi again,
You should try replacing the previous code with this:
function redirect_if_search_is_empty($wp_query) {
global $wp_query;
if ( $wp_query->is_search() && $wp_query->found_posts <=0 ) {
wp_redirect( 'http://wildernesstraveller.com/error404/' );
exit;
}
}
add_action('parse_query', 'redirect_if_search_is_empty');
Let us know how this goes!