Why is my loop not populating the page with my custom taxonomy terms from my custom post type? Currently it is displaying an empty box instead of pulling in the custom taxonomy terms from my custom post type series
. I am at a complete loss as to why this is. Any assistance that could be provided would be much appreciated!
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 10,
'paged' => $paged,
'taxonomy'=> 'series',
'field' => 'slug',
'orderby' => 'ID',
'order' => 'DESC'
);
$custom_query = new WP_Query( $args );
if ( have_posts() ) : while($custom_query->have_posts()) : $custom_query->the_post(); ?>
<div class="block_item article">
<div class="article_image" style="background: url('<?php the_field('series_artwork', $term); ?>'); background-size: cover; background-position: 50%;"></div>
<h4 class="section_label"><?php the_field('date', $term); ?></h4>
<div class="block_item_content">
<h3><?php echo $term->name; ?></h3>
<p><?php echo $term->description; ?></p>
<a href="<?php echo get_term_link($term->slug, 'series'); ?>" class="button_styling">
Read More
</a>
</div>
</div>
<?PHP endwhile; endif; ?>
<div class="clear"></div>
<?php // Pagination
if (function_exists("pagination")) {
pagination($custom_query->max_num_pages);
} ?>
Why is my loop not populating the page with my custom taxonomy terms from my custom post type? Currently it is displaying an empty box instead of pulling in the custom taxonomy terms from my custom post type series
. I am at a complete loss as to why this is. Any assistance that could be provided would be much appreciated!
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 10,
'paged' => $paged,
'taxonomy'=> 'series',
'field' => 'slug',
'orderby' => 'ID',
'order' => 'DESC'
);
$custom_query = new WP_Query( $args );
if ( have_posts() ) : while($custom_query->have_posts()) : $custom_query->the_post(); ?>
<div class="block_item article">
<div class="article_image" style="background: url('<?php the_field('series_artwork', $term); ?>'); background-size: cover; background-position: 50%;"></div>
<h4 class="section_label"><?php the_field('date', $term); ?></h4>
<div class="block_item_content">
<h3><?php echo $term->name; ?></h3>
<p><?php echo $term->description; ?></p>
<a href="<?php echo get_term_link($term->slug, 'series'); ?>" class="button_styling">
Read More
</a>
</div>
</div>
<?PHP endwhile; endif; ?>
<div class="clear"></div>
<?php // Pagination
if (function_exists("pagination")) {
pagination($custom_query->max_num_pages);
} ?>
Share
Improve this question
asked Oct 23, 2018 at 20:10
PeterPeter
1351 silver badge10 bronze badges
1
|
1 Answer
Reset to default 0You need to specify the post type in argument and need to use the taxonomy tag properly. You can try the following args variable.
$args = array(
'posts_per_page' => 10,
'post_type' => 'series', //Specify the post type here
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => '', //specify the taxonomy name
'field' => 'slug',
'terms' => '', //Specify the slug of what you want from the taxonomy
'operator' => 'IN',
)
)
'orderby' => 'ID',
'order' => 'DESC'
);
WP_Query
you'll need to use a function to get taxonomy terms instead. – WebElaine Commented Oct 23, 2018 at 20:19