Forums › Forums › Search & Filter Pro › Display when no match found
Tagged: result page for no match
- This topic has 5 replies, 2 voices, and was last updated 10 years, 8 months ago by
Anonymous.
-
Anonymous(Private) December 5, 2015 at 12:00 am #31494
Hi, thank you for the great plugin. Having had issues with previous versions I abandoned using S&F for a while but now the latest updates seem to have fixed some incompatibility issues with the theme.
At this stage of testing the issue I have is this:
Using display results as archive (it works great and I want it this way) when there is no match however s&f displays the WP standard “Ready to publish your first post? Get started here.
I have tried changing WP options from latest posts to static page to no avail. This is quite annoying.
Can S&F be configured to show a custom page or the themes template page “content-none.php” (as the theme does when using its built-in search) when there is no match in search or filter?
Thank you in advance for your guidance.
Anonymous(Private) December 7, 2015 at 9:20 pm #31647Just to elaborate a bit more – the premium theme has this in the search.php after the loop:
else :
// If no content, include the “No posts found” template.
get_template_part( ‘content’, ‘none’ );endif;
?>But it seems when there is no result searching/filtering with S&F this else statement is not honored. Any idea why?
Ross Moderator(Private) December 8, 2015 at 2:02 pm #31709Hi Niva
It depends on the template you are using.
So if you are in fact using
search.php, then the above seems correct.When S&F produces a search with no results, in your template
have_posts()will be false, which means theelse:part of your code will be run.What happens when you comment out the line:
//get_template_part( ‘content’, ‘none’ );?Does the message disappear?
Thanks
Anonymous(Private) December 8, 2015 at 9:25 pm #31758Thank you very much Ross for putting me on the right track. Indeed I had missed looking into what the content-none.pho contains (silly me!): that page has some weird conditions which I can comfortably change to display a custom message – one of those is the culprit:
<?php if ( is_home() && current_user_can( 'publish_posts' ) ) : ?> <p><?php printf( esc_html__( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.'), admin_url( 'post-new.php' ) ); ?></p> <?php elseif ( is_search() ) : ?> ...I’ll take it from here.
The one question that remains is should I enable is_search in S&F advanced tab (although it seems it doesn’t make any difference)?
Thank you again for the great support you are providing.
Ross Moderator(Private) December 8, 2015 at 9:32 pm #31763Hey Niva
is_search is an advanced setting which you should only really use if you know what you are doing.
Basically, some themes require
is_searchto be true in a query in order to display the search results template correctly with S&F – most do not.I think its preferable to leave this off.
Thanks
-
AuthorPosts