Answer the question
In order to leave comments, you need to log in
How to display all posts from a category on a separate page and pagination?
The situation is this, I made a cycle that displays a record on the main page, limited the records on the main page to 3 pieces. Because I want to transfer all the records to another page, with all Publications.
Here I am
<?php
$posts = get_posts( array(
'numberposts' => 3,
'category_name' => 'post',
'orderby' => 'modified',
'order' => 'DESC',
'post_type' => 'post',
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
) );
foreach( $posts as $post ){
setup_postdata($post);
?>
<div class="box">
<img src="<?php
if(has_post_thumbnail()){
the_post_thumbnail_url();
}else{
echo get_template_directory_uri() . '/assets/images/no-photo.png';
}
?>" alt >
<div class="box__inner">
<p><?php the_title();?></p>
<?php the_content();?>
<a href="<?php echo get_permalink(); ?>">Подробнее</a>
<p>
<?php echo get_the_date(); ?>
</p>
</div>
</div>
<?php
}
wp_reset_postdata();
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question