I’m trying to show posts in a slider from the category ‘sustainability’ but it just shows all posts?
its a vertical slider and it used to show posts from a cpt but now I want to show posts from the cat above. the posts need to show by cat id.
can anyone help and guide me in the right direction. Any help would be appreciated
<?php
$panelhead = $args['panelhead'];
//$panelintro = $args['panelintro'];
$panelimg = $args['panelimage'];
$panellink = $args['panellink'];
?>
<div class="fullcol pb-jobs-panel pb-padding">
<div class="midcol">
<div class="fullcol jobs-row jobs-row__top anim-target bottomfade-fm-dm">
<div class="jobscol copycol leftcol">
<?php
if($panelhead){
echo "<h3 class='key-heading'>".$panelhead."</h3>";
}
// if($panelintro){
// echo $panelintro;
//}
?>
</div>
<div class="jobscol rightccol"></div>
</div>
<div class="fullcol jobs-row">
<div class="jobscol leftcol imagecol anim-target bottomfade-fm-dm">
<?php
if($panelimg){
echo "<img src='".$panelimg['url']."' class='rounded-box' alt='".$panelimg['alt']."' title='".$panelimg['title']."' />";
}
if($panellink){
echo "<a class='nexbtn' href='".$panellink['url']."'>".$panellink['title']."</a>";
}
?>
</div>
<div class="jobscol rightccol carousel-column">
<div class="jobs-slider">
<?php
$i = 1;
//$recent = new WP_Query("post_type=resources&posts_per_page=12"); while($recent->have_posts()) : $recent->the_post();
$recent = new wp_Query($args); while($recent->have_posts()) : $recent->the_post();
$args = array(
'post_type' => 'post',
'posts_per_page' => 12,
'category_name'=>'sustainability',
);
?>
<div class="slide-item">
<div class="post-item rounded-box">
<h4><?php the_title(); ?></h4>
<?php the_excerpt(); ?>
<div class="post-link">
<a class="nexbtn" href="<?php the_permalink(); ?>">Read the full article</a>
<span class="date-resources"><?php echo get_the_date( 'd|m|y' ); ?> </span>
</div>
</div>
</div>
<?php
$i++;
endwhile; wp_reset_postdata(); ?>
</div>
<div class="button-wrapper">
<button class="slick-btn prev-btn-jobs-slider"></button>
<button class="slick-btn next-btn next-btn-jobs-slider"></button>
</div>
<!--<div class="progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100"></div>-->
</div>
</div>
</div>
</div>