• Resolved somtam

    (@somtam)


    Hi everybody,

    I am triggering the parse_query action to change the default query on category page.
    The problem is that I would like to make a different post_status for the post and the attachment.

    Null for attachment,
    Public or private for post.

    function ab_add_posts_attachments_to_category_query() {
       global $wp_query;
       if ( is_category() ) {
          $wp_query->query_vars['post_type'] =  array( 'post', 'attachment' );
          $wp_query->query_vars['post_status'] =  array( null );
          return $wp_query;
       }
    }
    add_action('parse_query', 'ab_add_posts_attachments_to_category_query');

    as you see in my code the post_status is NULL for everything!
    thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter somtam

    (@somtam)

    Solved,

    is enough to set:
    $wp_query->query_vars[‘post_status’] = array( ‘publish’, ‘inherit’, ‘private’ );

    thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘parse_query on category page’ is closed to new replies.