M
M
Mazino2018-07-06 12:40:53
WordPress
Mazino, 2018-07-06 12:40:53

How to get data of posts displayed on category page in wordpress loop?

There is a category page category.php , how to get the data of the posts output in the standard loop?
For example, if the page displays 10 entries, how to get the id and url of each of them without making a throne of crutches?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bodrosh, 2018-07-06
@Mazino

If in a standard loop, then you can do this:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
 <?php 
get_the_ID();
 the_title(); 
 the_excerpt();
 echo get_the_date();
?> 
<a class="br-button-el-link" href="<?php the_permalink(); ?>">Подробнее</a>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
 <?php endif; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question