• Resolved 2mooses

    (@2mooses)


    We have a large site with articles, and also recipes, the latter of which are using the WP Recipe Maker plugin. The recipes section has very good search functionality. However, in the search box of the main menu, we’d like to exclude recipes from appearing in those results, as it’s confusing to the user. (The main search box is presumably using WP Extended Search?)

    Is there a way to do this?

    Thanks for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Sumit Singh

    (@5um17)

    Hi,

    Of course, If the Recipe is custom post type you can just deselect it from settings in Extended Search > Search Setting: Select Post Types.

    Thanks

    Thread Starter 2mooses

    (@2mooses)

    Thank you. This is helpful, and I think I also see why it hasn’t been working. We’ve been adding the recipes from WP Recipe Maker to actual posts and using them that way. Is there a way instead to exclude a post category? In this case it’s a regular post, just with a Category “Recipes”. We don’t want it excluded from google search, just from the site global search, as we have a separate, and very effective, search for the recipes.

    Plugin Author Sumit Singh

    (@5um17)

    Hi,

    WPES currently do not have any feature of exclude posts from certain categories. But this is easy to do with WP API. You can add the below code to your theme’s functions.php and replace the 1 and 10 with categories IDs to exclude.
    In your case it just one category then Recipes category ID.

    
    /**
     * Exclude posts from some certain categories.
     *
     * @param WP_Query $q
     */
    function wpes_support_17810327( $q ) {
    	if ( function_exists( 'WPES' ) && WPES()->is_search( $q ) ) {
    		$q->set( 'category__not_in', [1, 10] ); // replace 1 and 10 with category IDs to exclude or add more category IDs.
    	}
    }
    add_action('pre_get_posts', 'wpes_support_17810327');
    

    PS:- If this works for you, please leave a review about product/support.

    Thanks

    Thread Starter 2mooses

    (@2mooses)

    Thank you, @5um17 This totally solved my problem.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.