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 Ernest Marcinko Ernest Marcinko 3 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31206
    uniconta18
    uniconta18
    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 Marcinko
    Ernest Marcinko
    Keymaster

    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
    uniconta18
    uniconta18
    Participant

    Thanks.

    This worked 🙂

    #31225
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    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.