Excluding pages from wp_query

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

This topic contains 3 replies, has 2 voices, and was last updated by

 
Keymaster
1 year ago.

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

    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

    Hi,

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

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #31219

    Participant

    Thanks.

    This worked 🙂

    #31225
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.