0

I have looked at multiple posts, but no luck. I need to use the loop how I have it for existing purposes, but I cannot figure out for the life of me how to return the terms of a custom taxonomy within a custom post type. Here is my code:

<?php $loop = new WP_Query( 

    'post_type' => 'dealmaker_pt', 
    'taxonomy' => 'topics',
    'field' => 'slug',
    'terms' => 'dealoftheweek',
    'posts_per_page' => 50,
    'offset' => 1 ) 
); 
        while ( $loop->have_posts() ) : $loop->the_post(); 
?>

stuffs here

<?php endwhile; wp_reset_query(); ?>

My post type is dealmaker_pt and my taxonomy is topics and I'm trying to display the specific taxonomy term of dealoftheweek.

How can I go about doing this?

2
  • You want only display the "dealmaker_pt" object where "topics = dealoftheweek" ? That doesn't work if you go to URL http:/ /DOMAIN/topics/dealoftheweek ?
    – mmm
    Oct 26, 2017 at 17:59
  • No, I am currently getting a server 500 error unfortunately.
    – Michael G
    Oct 26, 2017 at 18:03

1 Answer 1

2

Please use valid format for this Taxonomy Parameters

Example:

$args = array(
    'tax_query' => array(
        array(
            'taxonomy' => 'topics',
            'field'    => 'slug',
            'terms'    => 'dealoftheweek',
        ),
    ),
    'post_type' => 'dealmaker_pt',
    'posts_per_page' => 50,
    'offset' => 1 
);
$query = new WP_Query( $args );
1
  • Thank you, I marked the answer as the correct solution. Just doesn't show.
    – Michael G
    Oct 30, 2017 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.