• Apologies if I’m double-posting but I couldn’t find the answer although it seems my need might be common. I hope I’m asking the correct question (and furthermore that it makes sense).

    I’ve got several custom taxonomies that I’m using to describe a custom post type and I’m using taxonomy.php to display the posts that fall under a certain term. I’m using the QMT drilldown widget, but I’d like it to only show terms relevant to the posts that exist within that term.

    Here’s the page I’m working on: http://pittsculture.studiotwo.com/directory_categories/arts-and-culture/

    My master taxonomy is directory_categories and the term is arts-and-culture, so my page contains only arts-and-culture posts. However, you’ll see the drilldown widget is showing ALL terms from all taxonomies.

    My question: Is there a way to exclude terms that are not represented by the current taxonomy?

    I see the function below in widget.php. The current query is stored in $query as array('directory_categories'=>'arts-and-culture'). I’m thinking this could be passed into qmt_walk_terms() but couldn’t figure out what to do with it without hacking the plugin to bits. I’m hoping there’s an easy answer.

    private function generate_lists( $taxonomies ) {
    		$query = qmt_get_query();
    
    		$out = '';
    		foreach ( $taxonomies as $taxonomy ) {
    			$list = qmt_walk_terms( $taxonomy, $this->get_terms( $taxonomy ) );
    
    			if ( empty( $list ) )
    				continue;
    
    			$title = get_taxonomy( $taxonomy )->label;
    			if ( isset( $query[$taxonomy] ) ) {
    				$title .= ' ' . html( 'a', array(
    					'href' => QMT_URL::for_tax( $taxonomy, '' ),
    					'title' => __( 'Remove selected terms in group', 'query-multiple-taxonomies' ) )
    				, '(-)' );
    			}
    			$title = html( 'h4', $title );
    			$title = apply_filters( 'qmt_term_list_title', $title, $taxonomy, $query );
    
    			$out .=
    			html( "div id='term-list-$taxonomy'",
    				 $title
    				.html( "ul class='term-list'", $list )
    			);
    		}
    
    		$out .= self::reset_button();
    
    		return $out;
    	}

    http://wordpress.org/extend/plugins/query-multiple-taxonomies/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter lancemonotone

    (@lancemonotone)

    Nevermind…cracked it. This might be a bug because it seems like the widget is designed to do what I want (and as I said above, it seems like an obvious function), but $this->all_terms appears to be always set as 1 and so all terms are always returned.

    Commenting out the lines below did the trick.

    private function get_terms( $tax ) {
    		/*if ( $this->all_terms )
    			return get_terms( $tax );
    		else*/
    			return QMT_Terms::get( $tax );
    	}

    Did you have any trouble with the menu disappearing after you commented those lines? I tried this and my menu disappeared except for the search & reset buttons.

    Any suggestions? I am using 3.1 with the 1.4 QMT plugin.

    Thread Starter lancemonotone

    (@lancemonotone)

    I didn’t have any problems after hacking the function, but then again, I’m using QMT for a very specific purpose and it may be that any bugs I introduced just didn’t pop up.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Taxonomy Drill-Down] Can QMT Widget exclude terms outside current taxonomy?’ is closed to new replies.