Home › Forums › Support › Customizing Search Results – CPT's / Products This topic has 5 replies, 2 voices, and was last updated 4 years, 4 months ago by Tom. Viewing 6 posts - 1 through 6 (of 6 total) Author Posts October 26, 2017 at 9:52 am #410762 Brett Heya! I have a few sites on the go at the moment and they all require specific search results to be displayed. One site requires only WooCommerce products to show in the search results. Another site requires a selection of CPT’s (with all posts, pages, products hidden). Can I do this with some PHP? I guess I’m looking for info on how to add or hide post types from search results. Cheers, Brett October 26, 2017 at 11:32 am #410851 LeoStaff Customer Support Hi there, This should help: https://docs.generatepress.com/article/generate_navigation_search_output/ August 6, 2020 at 3:07 am #1389216 Giacomo Hi Leo, i see the page you linekd, but i don’t understand how i can haide product of woocommerce from search results. Can help me? August 6, 2020 at 2:26 pm #1390230 TomLead Developer Lead Developer Hi there, This should help: https://wordpress.stackexchange.com/a/231376/90661 To specify multiple post types, do this: add_action( 'pre_get_posts', function( $query ) { if( ! is_admin() && is_search() && $query->is_main_query() ) { $query->set( 'post_type', array( 'page', 'post' ) ); } } ); August 6, 2020 at 10:39 pm #1390672 Giacomo Thanks Tom, works perfect ๐ August 7, 2020 at 8:52 am #1391696 TomLead Developer Lead Developer You’re welcome ๐ Author Posts Viewing 6 posts - 1 through 6 (of 6 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In