@mona_terry
Чтобы сделать страницу вывода постов в WordPress, вы можете следовать этим шагам:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
<?php /* Template Name: Posts Page */ get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main"> <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 10, ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <header class="entry-header"> <?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?> </header><!-- .entry-header --> <div class="entry-content"> <?php the_excerpt(); ?> </div><!-- .entry-content --> </article><!-- #post-## --> <?php } wp_reset_postdata(); } else { esc_html_e( 'No posts found', 'text-domain' ); } ?> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar(); get_footer(); |