Types & Views: Excluding posts/pages from a view.

This is also a good snippet for manipulating WP_Query args in general. For stuff Views doesn’t provide a GUI for yet.

Instructions

Add code in your theme/functions.php (Although creating a Plugin would be better, so we don’t have issues if themes are changed later on)

add_filter('wpv_filter_query', 'exclude_specific_page_func', 10, 2);

function exclude_specific_page_func($query, $settings)
{
  if($settings['view_id'] == 123)
  {
    $query['post__not_in'][] = 456;
    $query['post__not_in'][] = 457;
    $query['post__not_in'][] = 458;
  }
  return $query;
}

Source

Views: Post parent is -not- specific page

More info

Screenshot

Leave a Reply

Your email address will not be published. Required fields are marked *

Markdown is allowed in comments.