V
V
vintalis2020-05-11 17:46:30
WordPress
vintalis, 2020-05-11 17:46:30

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

cycle
<?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(); 
?>

All work out records are published.
Now I want to make the output of these records on a new page, but already all the records. I created a new php file, named it, inserted the same code, and it seems to come out correctly, records are published on the new page and on the main page.
But this is not the right solution, because the breadcrumbs then do not work correctly, and the post category comes out and remains on the main page and the breadcrumbs take me back to the main page, and the idea is that, on the new page that I created.

How can I make a new page with all the posts in the ''post' category so that the url structure is preserved.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vintalis, 2020-05-11
@vintalis

I found a solution, category.php is responsible for Categories. What would be the concepts, https://wp-kama.ru/id_7654/ierarhiya-fajlov-temy-s... the whole hierarchy, that is, the WordPress structure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question