• Resolved rossdowney333

    (@rossdowney333)


    Hello,

    I’m wondering how I can remove event submissions from appearing in my site-wide search.

    I’m using the default search function.

    Thanks,
    Ross

Viewing 1 replies (of 1 total)
  • Plugin Author Rita Kikani

    (@kikanirita)

    Hi @rossdowney333 ,

    This is wordpress core functionlality, So we can not exclude any particular page from our plugin. But, you can exclude particular page from your site search, for that you need to add below code in your them functions.php file.

    add_action('pre_get_posts','wp_event_submit_form_exclude_posts_from_search');
    function wp_event_submit_form_exclude_posts_from_search( $query ){
    
        if( $query->is_main_query() && is_search() ){
             //Exclude posts by ID
             $post_ids = array(6); // Here you have to pass id of your page which you want to exclude from default search
             $query->set('post__not_in', $post_ids);
        }
    }

    In above code, $post_ids you have to add your submit event form page Id.

    I hope this code snippet will help you to resolve your query.

    Thank you.

Viewing 1 replies (of 1 total)
  • The topic ‘Remove event posts from site search’ is closed to new replies.