This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Excluding pages from wp_query

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Excluding pages from wp_query

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31206
    uniconta18uniconta18
    Participant

    Hi

    I will be having many search bars in my website and I do not wish to exclude some posts/page ids on each of them. I have always used the below code:

    if ( ! $query->is_admin && $query->is_search ) {
            $query->set( 'post__not_in', $pages_array );
    }

    But this does not seem to be working with your plugin. Can you please help with this ?

    Thanks.

    #31209
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Sure, you are looking for the asp_query_args hook.
    The post_not_in key is the one to exclude pages.

    #31219
    uniconta18uniconta18
    Participant

    Thanks.

    This worked 🙂

    #31225
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

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