0

Having an issue trying to query the most recent posts using the tag, in this case, trending. I used the following code but I get no results. If I switch out 'tag' to 'post_type' it will work:

<?php $args = array(
    'tag' => 'trending',
    'posts_per_page' => '1',
);
$queryone = new WP_Query( $args ); ?>

<?php while ($queryone -> have_posts()) : $queryone -> the_post(); ?>
<?php
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array(5600,1000 ), false, '' );
?>
<div class="feature" style="background: url(<?php echo $src[0]; ?> ) no-repeat top center!important; background-size: cover!important;">
<div class="feature-bottom"><h3><?php echo get_post_type( $post ) ?></h3><h2><?php echo get_the_title( $ID ); ?> </h2></div>
</div>
<?php endwhile; ?>
0

Found the problem. In my args, I should have included this line:

'post_type' => array( 'one', 'two', 'three', 'four', 'five', 'six' ),

above the 'tag' arguments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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