Skip to:

Tag Exclusion in Views/Loops

  • I have been trying to implement tag exclusion in custom views and loops, without success.

    I was looking at registering a custom view (example below) with the tag excluded. I assume this means adding ” AND tag_id !=xxx” or similar to the query, but I can’t find out how to do this.

    $args = array( ‘order_by’ => ‘topic_title’, ‘order’ => ‘DESC’ );

    bb_register_view( ‘alphabetical-descending’, __(‘Alphabetical: Descending (Z — A)’, ‘desc’), $args, false );

    I also tested a more hackish method (requires core edits for proper pagination) from another thread:

    function filter_front_page_topics($where){

    $exclude_tags=array (“<tagid goes here>”);

    if ( is_front() ) {foreach($exclude_tags as $tag) { $where.=” AND tag_id != “.$tag.” “; }}

    return $where;


    This returns no posts, though the original version for forum exclusion works…

    Any suggestions about how to proceed with either approach would be appreciated.

You must be logged in to reply to this topic.