- This topic has 11 replies, 3 voices, and was last updated 6 years, 1 month ago by
Leo.
-
AuthorPosts
-
January 15, 2020 at 3:09 am #1132667
Nacho
Hello,
How would you exclude the GP search funcionanility from searching pages?
Thanks a lot.
January 15, 2020 at 8:48 am #1133118Leo
StaffCustomer SupportHi there,
We will need this filter:
https://docs.generatepress.com/article/generate_navigation_search_output/Do you only want to search for posts?
Let me know 🙂
January 15, 2020 at 9:16 am #1133146Nacho
Hi Leo,
Yes I just want to search for posts not pages.
Thanks!
January 15, 2020 at 10:53 am #1133260Leo
StaffCustomer SupportTry this PHP snippet:
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/
January 15, 2020 at 12:07 pm #1133356Nacho
Hello Leo,
I´ve just put the code but it´s not working.
I´ve tried in the live version so I´ve updated this post website URL.
If you search for example the word “tour” it will show the tour page and that´s a page not a post.
Thanks a lot.
January 15, 2020 at 12:37 pm #1133382Leo
StaffCustomer SupportI’m not seeing the navigation search in the URL provided.
Can you double check?
Let me know 🙂
January 16, 2020 at 1:41 am #1133775Nacho
Hello Leo,
I´ve just updated the url so you can see the search box.
Thanks a lot.
January 16, 2020 at 10:20 am #1134359Tom
Lead DeveloperLead DeveloperHi there,
It doesn’t look like you’re using the Navigation Search.
Are you wanting to target the search bar in your right sidebar?
January 16, 2020 at 10:59 am #1134378Nacho
Hi Tom,
Oh yes the search bar in the sidebar. Actually I thought it was the same.
What should I do?
Thanks a lot.
January 16, 2020 at 2:48 pm #1134498Leo
StaffCustomer SupportThat’s a WordPress search widget which is different than GP’s navigation search:
https://www.wpbeginner.com/wp-tutorials/how-to-exclude-pages-from-wordpress-search-results/January 17, 2020 at 1:01 am #1134743Nacho
Hi Leo,
Understood. That worked like charm.
Thanks a lot for the help to all of you and have a good day.
January 17, 2020 at 6:26 am #1135010Leo
StaffCustomer SupportNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.