Support » Plugin: Query Multiple Taxonomies » [Plugin: Query Multiple Taxonomies] Error if empty results when querying multiple taxonomies

  • Resolved chymera00

    (@chymera00)


    When making a query of multiple taxonomies, the results come up fine if there’s a match found. However if no match is found, the query prints out ALL of my posts. Am I doing something wrong here?

    I’m using wordpress 3.0.1 and query multiple taxonomies 1.3alpha
    (also used 1.2 with same results)

    <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;

    $args=array(
    ‘destinations’ => ‘palawan’,
    ‘classification’ => ‘attractions’,
    ‘paged’ => $paged,;

    query_posts($args);

    if ( have_posts() ) : while ( have_posts() ) : the_post();

    query_loop_list(); ?>
    <?php endwhile; ?>
    <center><?php wp_pagenavi(); ?></center>

    <?php else: ?>
    <?php endif; ?>

    <?php wp_reset_query(); ?>

Viewing 15 replies - 1 through 15 (of 15 total)
  • same issue here, wp 3.0.1 and query multiple taxonomies 1.2
    here is my code (works fine when matches, shows everything when not)

    <?php query_posts("partner=bill&brand=ford"); ?>
    <?php while (have_posts()) : the_post(); ?>
    <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>

    Hi

    I’m having a similar problem but instead of getting all my posts shown the plugin is generating a 404 error.

    WordPress: Version 3.0.1.
    Plugin: Version 1.2.3

    Line 76 in ‘core.php’ appears to be generating this 404 result:

    if ( empty( self::$post_ids ) )
    			return $wp_query->set_404();

    Rather than generating a 404 error I want the page to reload with an empty post set so I can use the standard loop and have_posts() function to generate my page content:

    <?php if (have_posts()) : ?>
    			<!-- do something with posts -->
    		<?php else : ?>
    			<!-- show 'no posts' message -->
    		<?php endif; ?>

    Anybody have any ideas?

    Plugin Author scribu

    (@scribu)

    This should be fixed in the latest development version (1.3-alpha2).

    hi scribu,
    it’s fixed but there is a new issue:

    if i query multiple terms for one taxonomy, it shows again ALL my posts, from every tag and category.
    <?php query_posts("cat=5&partner="bill,robert,john");?>

    if i query one term works fine:
    <?php query_posts("cat=5&partner="bill");?>

    if i query multiple taxonomies and multiple terms works fine again!
    <?php query_posts("cat=1&brand=ford&partner=bill,robert,john");?>

    Plugin Author scribu

    (@scribu)

    Yeah, besides that, the ‘cat’ parameter was ignored. Both bugs are now fixed. Please re-download the development version (1.3-alpha4).

    thank you scribu!
    but i found a new bug…

    if i query just one term i get posts for all partners
    <?php query_posts("cat=5&partner="bill");?>

    i found a workaround adding a fake partner in the query
    <?php query_posts("cat=5&partner="bill,fakepartner");?>
    but it’s a bit hacky.

    thank you for your work, i’m definitely going to donate. =)

    Plugin Author scribu

    (@scribu)

    A better workaround would be to use category_name instead:

    <?php query_posts("category_name=your-category-slug&partner="bill");?>

    thanks for the reply scribu. Much appreciated!

    Found a problem with development version (1.3-alpha4). I’m using the multiple taxonomy queries in my taxonomy.php
    The taxonomy templates display fine during the past versions but it’s all messed up now.

    Just for more info my taxonomy.php is built around

    <?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); ?>

    then using $term->slug and $term->name for the queries

    Found out that my taxonomy.php is being bypassed and it goes directly to archive.php for the template.

    Plugin Author scribu

    (@scribu)

    Just for more info my taxonomy.php is built around

    <?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); ?>

    A better way to do it is:

    $term = $wp_query->get_queried_object();

    Of course, that won’t work when you’re querying multiple terms, like ?color=green,yellow or ?color=green&shape=round.

    I usually create a multitax.php file and then replace everything in taxonomy.php with this:

    include_once './multitax.php';

    scribu — Thanks a million for the plugin.
    1.3 alpha 4 WP 3.0.1

    With the plugin deactivated the following works like a charm:

    $args = array(
    ‘post_type’ => ‘restaurants’,
    ‘post_status’ => ‘publish’,
    ‘posts_per_page’ => -1,
    ‘order’ => ‘ASC’,
    ‘orderby’ => ‘title’
    );
    query_posts($args);

    When the plugin is activated the above returns nothing.

    I tested and if I don’t query a taxonomy for a custom post type it displays nothing, yet if I create a dud custom taxonomy called “things” with term “thing” and assign it to each of my posts the following works like a charm:

    $args = array(
    ‘post_type’ => ‘restaurants’,
    ‘post_status’ => ‘publish’,
    ‘posts_per_page’ => -1,
    ‘order’ => ‘ASC’,
    ‘orderby’ => ‘title’,
    ‘things’ => ‘thing’
    );
    query_posts($args);

    Can the next update include a fix for this? I’m under a crazy deadline, so please let me know if this is an easy/fast fix and when you think it might be available.

    Thanks again 100000000000 🙂

    Plugin Author scribu

    (@scribu)

    1.3-alpha5 will be available in about 15 minutes after I write this.

    That fixed it. Much appreciated scribu. YOU RULE!

    Plugin Author scribu

    (@scribu)

    I usually create a multitax.php file and then replace everything in taxonomy.php with this:

    include_once ‘./multitax.php’;

    That is no longer necessary. All queries are now directed to taxonomy.php:

    development version (1.3-alpha6).

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘[Plugin: Query Multiple Taxonomies] Error if empty results when querying multiple taxonomies’ is closed to new replies.