YOU ARE A GENIUS🙏🏻 An entire morning wasted thinking that it was me who was wrong... I think it's ridiculous though that the Elementor guys don't take care of this... moreover, in another video, you talked about the possibility of EXCLUDING, for example, posts from the search results of products. Well, this is possible with products, but not with POSTS: if I select EXLUDE, I don't have the possibility to insert pages, but only categories and tags... so little would be enough... Thanks again for the trick
Great tips thanks. What would I need to type in the code if I just wanted to exclude certain pages but not others? So to list say the "checkout" page as being excluded specifically?
@@websquadron thanks, I found a wee bit of code which worked a charm by just replacing the numbers in the array with my page ID's I wanted to be excluded from my search results. Love that wee snippet plugin you recommended! :) add_action( 'pre_get_posts', 'my_search_exclude_filter' ); function my_search_exclude_filter( $query ) { if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) { $query->set( 'post__not_in', array( 10854, 8232, 7113 ) ); } }
Great video, came across a bug in the code, when searching for a page title it lists all the posts rather than showing no match found, any fix for that? Thanks
Is it possible to add suggested posts if the search results are not found? Awesome tutorial by the way. I've been looking for this solution for like, a day. Thank you!
@@websquadronThanks! I've assigned categories and opted to exclude them in the publish settings, but the search still isn't excluding the specified categories. I think the problem is occurring on the code snippet side of things. Toying with the code hasn't gotten me anywhere either. Any other insights would be wonderful as WP and Elementor support have been absent!
@@websquadron Yes! once I used the Code Snippet plugin it worked. It's asham the custom code section in elementor didn't work. I like to reduce the amount of plug-in I'm using. But in any case this was still helpful
YOU ARE A GENIUS🙏🏻
An entire morning wasted thinking that it was me who was wrong... I think it's ridiculous though that the Elementor guys don't take care of this... moreover, in another video, you talked about the possibility of EXCLUDING, for example, posts from the search results of products. Well, this is possible with products, but not with POSTS: if I select EXLUDE, I don't have the possibility to insert pages, but only categories and tags... so little would be enough...
Thanks again for the trick
Another brilliant fix for a common issue. Thank you so, so much!
Simple issue but great impact! Thanks for this
Great tips thanks. What would I need to type in the code if I just wanted to exclude certain pages but not others? So to list say the "checkout" page as being excluded specifically?
Easiest way is to stop them from being indexed as there’s no need for them to be visible in search results
@@websquadron thanks, I found a wee bit of code which worked a charm by just replacing the numbers in the array with my page ID's I wanted to be excluded from my search results. Love that wee snippet plugin you recommended! :)
add_action( 'pre_get_posts', 'my_search_exclude_filter' );
function my_search_exclude_filter( $query ) {
if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) {
$query->set( 'post__not_in', array( 10854, 8232, 7113 ) );
}
}
Thanks a lot! Quick and easy!!!!
hey thanks brother.. worked like a charm!
Great video, came across a bug in the code, when searching for a page title it lists all the posts rather than showing no match found, any fix for that? Thanks
Did you find the answer?
Is it possible to add suggested posts if the search results are not found?
Awesome tutorial by the way. I've been looking for this solution for like, a day. Thank you!
Good question, and I suspect not.
Hey, what if I just want to display let say just posts with product categories?
Let me have a think
@@websquadron thank you that will be very helpful :D
Please, how can I include Videos in search. Thank you
Depends how they are added?
As Custom Posts with relevant Tags?
@@websquadron I used All in one video plugin, and making video post from there. How can I include them in my search page using your snippet code.
I tried but it's not working. Still pages are visible in search results. Please help.
The codes are in the link in the description, it worked for me.
Hi, that not work with Blocksy theme. :-((
I never said it did work with Blocksy
My website has no posts; only pages. How can I use this to hide some pages from the search but leave others visible?
You may need to assign categories to the pages. I have a video on that somewhere
@@websquadronThanks! I've assigned categories and opted to exclude them in the publish settings, but the search still isn't excluding the specified categories. I think the problem is occurring on the code snippet side of things. Toying with the code hasn't gotten me anywhere either. Any other insights would be wonderful as WP and Elementor support have been absent!
For some reason Products are still showing up in my search results.. Double checked everything.
And you’ve set the display conditions etc
@@websquadron yes I have Search Results included
@@websquadron I even tried adding a tag to the products cleared cache and the tags wont show up in exclude tags condition
Just tried this by using the elementor Custom Code section, and unfortunately it didn't work.
That's why I normally recommend adding to the Code Snippets Plugin:)
@@websquadron Yes! once I used the Code Snippet plugin it worked. It's asham the custom code section in elementor didn't work. I like to reduce the amount of plug-in I'm using. But in any case this was still helpful
The custom code is more for styling than functions hence why it doesn’t work well. Don’t worry as the code snippets plugin is super light.
Where is the code?
Did you click the link in the Video Description?
Works but too good. I have an elementor page builder search results archive and it's hiding the results from that (apparent) 'page' ?? Lol.
Can you share more details?
@@websquadron I figured it out somehow. I don't remember. Lol. You rock for replying! Keep up the good work!
2000 hp at your disposal...Do you want to drive it?