CPT called: updates
Custom Taxonomy called: systems
What I was trying to do was loop through all my posts in a CPT and display the '1' latest post from each of my 'I think they're called Terms' (it's referred to as a Category under posts).
One of my terms is called 'website' so I've edited my logic just to try and get the latest posts in my CPT called 'updates under the taxonomy called systems and in a term called website'.
But no matter what I do it just returns Sorry, no posts matched your criteria.
I really don't understand what I'm doing wrong. Markup and logic below:
<div class="col-md-12">
<!-- News SECTION -->
<?php
$args = array(
'post_type' => 'updates',
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'date',
'posts_per_page' => 1,
'tax_query' => array(
array(
'taxonomy' => 'systems',
'field' => 'slug',
'terms' => 'website'
//'parent' => 0
)
)
);
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('mt-4'); ?>>
<div class="row">
<div class="col-sm-3">
<?php the_post_thumbnail('medium', ['class' => 'img-fluid medium', 'title' => 'Feature image']); ?>
</div>
<!-- /close Col-4 -->
<div class="col-sm-9">
<header class="entry-header home">
<?php
if ( is_single() ) : the_title( '<h1 class="entry-title">', '</h1>' );
else : the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
endif;
?>
<div class="entry-meta">
<strong><?php echo get_the_date('d-m-Y'); ?></strong>
by <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>">
<strong><?php the_author(); ?></a></strong>
</div><!-- .entry-meta -->
</header><!-- .entry-header -->
<div class="entry-content home">
<?php
if ( is_home() or is_front_page() ) :
// if ( is_front_page() ) :
the_excerpt();
else :
the_content(
sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'system_updates' ),
array(
'span' => array(
'class' => array(),
),
)
),
wp_kses_post( get_the_title() )
)
);
endif;
?>
</div><!-- /.entry-content -->
</div><!-- /.col -->
</div><!-- /.row -->
<hr>
</article><!-- #post-<?php the_ID(); ?> -->
<?php endwhile ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
<!-- /News SECTION -->
</div><!-- /.col 12 -->