Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Display posts from category in descending date order WordPress


This is what my code looks like now:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>

<div class="blog-cont">
<h3><?php the_title(); ?></h3>
<div class="entry">
<!-- entry-->
Posted on <?php the_time("F, d, Y"); ?> by <a href="#"><?php the_author(); ?> - </a>

‪<a href="<?php the_permalink() ?>#comments"><span><?php comments_number('0','1','%')?> Comments</span></a>‬
<div class="box-blog">
<!-- box blog-->
<div class="img-box">
<?php the_post_thumbnail('medium'); ?>
<div class="text-box-blog">
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>" class="btn"><span>Continue reading &#187;</span></a>

<?php endwhile; endif; ?>

Answers (1)


Kailey Lampert answers:

Put this before the code that you have now.

$cat_id = CATEGORY_ID; //replace with actual category ID :)

Louis Gubitosi comments:

Sorry, I don't have a category ID. This is dynamic for all categories.

Kailey Lampert comments:

In that case, you should be able to use this
$cat_id= get_queried_object_id();