Forums › Forums › Search & Filter Pro › Search result is always interpreted as is_front_page, is_home
- This topic has 13 replies, 2 voices, and was last updated 6 years, 1 month ago by Trevor.
-
Anonymous(Private) October 12, 2018 at 12:58 pm #190873
The search results page is always interpreted as is_front_page or is_home. You can also see that the class home is set in the body tag.
Due to this behavior it is not possible to use the queries is_front_page or is_home.
From my point of view this is a bug. The option “Force is_search to always be true?” or “Force is_archive to always be true?” doesn’t help at all.
What is the solution?
Concrete problem: On the result page I get a slider because the page is interpreted as front_page or home.Translated with http://www.DeepL.com/Translator
Trevor(Private) October 12, 2018 at 4:44 pm #190892It is your theme that is doing this. I also notice that you do not seem to have an archive.php template.
The search.php is calling the WordPress body_class() function. Using your functions.php, you can hook in to this and remove the blog and home classes. You can use force is_search to add the search body class.
As there is no ‘real’ page called ‘filter’, your code would then look to see if the page being loaded has the search body class, and if so, remove the blog and home classes:
add_action( 'body_class', 'my_custom_search_class'); function my_custom_search_class( $classes ) { // Remove 'blog' class if ((in_array('blog', $classes)) && (in_array('search', $classes))) { unset( $classes[array_search('blog', $classes)] ); } // Remove 'home' class if ((in_array('home', $classes)) && (in_array('search', $classes))) { unset( $classes[array_search('home', $classes)] ); } return $classes; }
As long as that runs after our plugin adds the search class, all should work, otherwise it might need a low priority set.
-
AuthorPosts