Support » Plugin: Search Exclude » Include in Custom Query

  • Is there a way to force the inclusion of the search excluded posts in a custom query? Currently once checked, the plugin removes it from custom queries, as well.


Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author pronskiy


    Hi @tokyobear,

    Could you give an example of such custom query?

    In general, the plugin should not affect it, because there is a check $query->is_search which means it should only affect search queries.

    It is always possible to do $query->set('post__not_in', []);.
    But if you provide an example of your query I could come up with a more elegant solution.

    Thread Starter tokyobear


    Thank you for the prompt response. The below is the code that is used on a single.php page in the theme (i.e. within another post). $postarea is defined through a custom field. The filter works as intended. But if I check “Exclude from Search Results” in any one of the posts then it disappears from the results. Thank you in advance for the help.

    // define query parameters based on attributes
    $options = array(
    ‘post_type’ => ‘post’,
    ‘posts_per_page’ => -1,
    ‘relation’ => ‘AND’,
    ‘tax_query’ => array(
    ‘taxonomy’ => ‘location’,
    ‘field’ => ‘slug’,
    ‘terms’ => $postarea,
    ‘include_children’ => true,
    ‘operator’ => ‘IN’,

    $query = new WP_Query( $options );

    // run the loop based on the query
    if ( $query->have_posts() ):?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Include in Custom Query’ is closed to new replies.