Support » Fixing WordPress » custom taxonomy WP_Query() with custom post type comes up empty

  • Hello,

    I have been struggling for several days with filtering a custom post type (“testimonial”) by a custom taxonomy (“quote-page”).

    My post type query works fine until I add the taxonomy, at which point it returns no posts.

    I have tried renaming the taxonomy several different ways, looking for conflicts

    Here’s the taxonomy registration code:

    function quotepage_init() {
    			'label' => __('Quote Page'),
    			'sort' => true,
    			'args' => array('orderby' => 'term_order'),
    			'query_var' => true,
    			'hierarchical' => true,
    			'rewrite' => array('slug' => 'quote-page')
    add_action( 'init', 'quotepage_init' );

    The post type registration:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    And the Query :

    <?php $args = array(
    			'post_type' => 'testimonial',
    			'quote-page' => 'river-trips',
    			'orderby' => 'rand',
    			'showposts' => '-1',
    		$testimonials = new WP_Query($args);

    There is one testimonial with “river-trips” as its quote-page value, which I have verified using echo the_terms( $post->ID, 'quote-page');

    I have tried most of the variations suggested in this thread to no effect:

    Can anyone see what I’m doing wrong? Thanks in advance for any help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Please ignore this second post – clumsiness with the forum software…

    I just realized that when I said “please ignore”, one might have thought I meant the entire topic, and not just the extra post.

    I do really need some help, if anyone can offer it. Thanks very much for any suggestions.


    The code works when I use a taxonomy terms without hyphens in it.

    ‘river-trips’ does not work, but ‘directions’ does.

    Does anyone know of a problem with punctuation within a taxonomy?

    Final Update:

    Turns out it was not a punctuation problem, but a slug problem.

    When I viewed the dashboard page for my taxonomy, I found that ‘river-trips’ apparently had been created, deleted, and created again, because its slug was not ‘river-trips’ but ‘river-trips-2’, causing my code not to work.

    Now I’m headed to manually edit the database to try to get rid of any trace of the original slug so my code can work…

    But the problem above can be considered resolved.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘custom taxonomy WP_Query() with custom post type comes up empty’ is closed to new replies.