Как можно выводить посты на отдельной странице?

Посты выводит на главной, нужно на отдельной, как это сделать?

<?php if ( have_posts() ) : ?>

			<?php if ( is_home() && ! is_front_page() ) : ?>
				<header>
					<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
				</header>
			<?php endif; ?>

			<?php if ( 'top' == root_get_option( 'structure_home_position' ) ) get_template_part( 'template-parts/home', 'content' ); ?>

			<?php
			if ( is_front_page() || is_home() ) {
				if ( root_get_option( 'structure_slider_width' ) == 'content' ) {
					$is_show_on_paged   = root_get_option( 'structure_slider_show_on_paged' );
					if ( ! is_paged() || ( $is_show_on_paged && is_paged() ) ) {
						get_template_part( 'template-parts/slider', 'posts' );
					}
				}
			}
			?>

			<?php get_template_part( 'template-parts/layout/archive', root_get_option( 'structure_home_posts' ) ); ?>

			<?php the_posts_pagination(); ?>

			<?php if ( 'bottom' == root_get_option( 'structure_home_position' ) ) get_template_part( 'template-parts/home', 'content' ); ?>

		<?php else : ?>

			<?php get_template_part( 'template-parts/content', 'none' ); ?>

		<?php endif; ?>
0
konstantin-zhevzhik
4.5 лет назад
  • 0
    kolshix 784 paxtoy.com

    вот кусок моего кода на отдельной странице, подправите под себя
    WP_Query{}

    <?php
    /**
     * Template for displaying Rand Results pages
     *
     * @package WordPress
     * @since GTF 2.0
     */
    
    	$the_query = new WP_Query( array (
    					'orderby' => 'rand',
    					'posts_per_page' => '4') );
    	// output the random post
    	$random_post = '';
    	while ( $the_query->have_posts() ) : $the_query->the_post();                    
    		$post_permalink = get_the_permalink( $post->ID );
    		$post_thumbnail = get_the_post_thumbnail_url( $post->ID ,'medium' );
    
    		$random_post .= '<a class="rand-grid" href="'. $post_permalink.'"><img alt="'. get_the_title( $post->ID ) .'" class="rand-i" src="'. $post_thumbnail .'"></a>'."\n\t\t\t\t\t\t\t\t";
    
    	endwhile;           
    
    	// Reset Post Data
    	wp_reset_postdata();
    
    echo $random_post; 
    ?>
    Комментировать
На вопросы могут отвечать только зарегистрированные пользователи. Вход . Регистрация