Archived topic
Search Results Filter
3 replies · Started by Sourabh on December 9, 2020
HI David/Tom,
I have created a search page but when I search any post, So along with post, Pages also coming in to search results, so how to filter that, I contacted with elementor team so they said it could be done via custom CSS and I need to contact theme developer for that, See if you can help to apply such filter -
https://www.dropbox.com/s/rtym5rzo50d6vms/pages%20in%20search%20results.png?dl=0
the above image will you an idea of what I am trying to say.
Hi there,
If you are referring to GP's navigation search option in the main navigation then this PHP snippet should work:
add_filter( 'generate_navigation_search_output', function() {
printf(
'<form method="get" class="search-form navigation-search" action="%1$s">
<input type="search" class="search-field" value="%2$s" name="s" title="%3$s" />
<input type="hidden" name="post_type" value="post" />
</form>',
esc_url( home_url( '/' ) ),
esc_attr( get_search_query() ),
esc_attr_x( 'Search', 'label', 'generatepress' )
);
} );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Okay Thanku, I will Try and Update...
Sounds good :)