Support » Plugin: Query Multiple Taxonomies » Query Taxonomies AND custom fields

Viewing 12 replies - 1 through 12 (of 12 total)
  • I combined QMT with Custom Query Fields Plugin. Works great!

    How did you combined them? I’m interested too into this!

    Axenstar86, could you please email me at neodjandre @gmail. com

    as I would like some work to be done!


    Bump for help!

    @maraki Did you received some infos about to combine this two plugins from Axenstar86?

    Thank you!

    Hey all, I’ll post some example code later this day.

    Thank you Axenstar86, you don’t know how much i can appreciate this!
    Thank you!

    So guys here is my code to query custom fields AND taxonomies:

    1st I made some changes to the qmt-template “checkboxes.html” and “dropdowns.html” (as I use checkboxes and dropdowns for my form)


    <form method="get" action="{{base-url}}" class="custom taxonomy-drilldown-checkboxes">
    	<div id="terms-{{taxonomy}}">


    <form method="get" action="{{base-url}}" class="taxonomy-drilldown-dropdowns">
    			<select id="qmt-{{name}}" name="{{name}}">
    				<option value=''>{{{any-text}}}</option>

    As I’m going to extend the forms with custom fields, I’lll close it later.

    Now in my wordpress theme template ( in my case : archive.php) I built this extended form Just change the field names and keys etc that it fits your needs:

    <!-- Query Multiple Taxonomies AS CHECKBOX -->
    			the_widget('Taxonomy_Drill_Down_Widget', array(
    			'title' => '',
    			'mode' => 'dropdowns',
    			'taxonomies' => array( 'tax1, tax2') // list of taxonomy names
    <!-- Query Multiple Taxonomies AS DROPDOWN -->
    		the_widget('Taxonomy_Drill_Down_Widget', array(
    		'title' => '',
    		'mode' => 'checkboxes',
    		'taxonomies' => array( 'tax3, tax4') // list of taxonomy names
    <!-- Now we combine the form with custom fields -->
    <?php $custom_fields = get_meta_values( 'cf_key', 'cf_value' ); // Get all Meta Values associated with Key ?>
    <!-- Get CF Min Value -->
    <select name="album_rating_min" id="rating_min"> 
    	<option value="">-</option>
    	<?php foreach($ratings as $rating){
    		echo '<option value="' . $rating . '"' . ($rating == $_GET["album_rating_min"] ? ' selected="selected"' : '') . '>' . $rating . '</option>';  //Echo all Rating Values as Options
    	} ?>
    <!-- Get CF Max Value -->
    <select name="album_rating_max" id="rating_max"> <!-- Get Rating Max Value -->
    	<?php foreach($ratings as $rating){
    		echo '<option value="' . $rating . '"' . ($rating == $_GET["album_rating_max"] ? ' selected="selected"' : '') . '>' . $rating . '</option>';  //Echo all Rating Values as Options
    	} ?>
    <!-- Let's submit our combined form -->
    <input type="submit" value="filter" />
    <!-- Close the form started in the qmt-templates -->

    “$custom_fields” should be “$ratings”

    Axenstar86, thank you, I’m also working on this feature… quick question: did you use “get_meta_values” from this post: ? or did you develop another one?

    Yeah I believe it’s the same. To be sure here is my code:

    function get_meta_values( $key = '', $type = '', $status = 'publish' ) {
        global $wpdb;
        if( empty( $key ) )
        $r = $wpdb->get_col( $wpdb->prepare( "
            SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm
            LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
            WHERE pm.meta_key = '%s'
            AND p.post_status = '%s'
            AND p.post_type = '%s'
    		ORDER BY ( CASE pm.meta_value
    			WHEN '10' THEN 1
    			WHEN 'Keine Bewertung' THEN 999
    			ELSE 100 END) ASC, pm.meta_value DESC
        ", $key, $status, $type ) );
        return $r;

    That’s super Axenstar!
    I’ll try to implement it with lists, as i’m using them for my qmt widget.

    Thank you so much, i’ll report if i’ll achieve my goal!

    I also implemented it using lists and is working pretty well!

    I HAD to make some minor changes to the core, since there was a problem with pagination and the query was not working well. Don’t know if it’s only me, but here is what worked for me. In core.php, line 147, from:

    $query[ $taxonomy ] = trim( implode( '+', $value ), ',' );


    $query[ $taxonomy ] = trim( implode( ',', $value ), ',' );

    I did the same change in walkers.php (replacing “+” with “,”) in lines 41 and 84.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Query Taxonomies AND custom fields’ is closed to new replies.