if ( is_page() ) {
// тут необходимый код
}
if ( is_page(9) ) { // в Page с id=9
// тут необходимый код
}
<?php
$custom_query = 'posts_query';
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
);
${$custom_query} = new WP_Query( $args );
while ( ${$custom_query}->have_posts() ) : ${$custom_query}->the_post();
?>
<?php
endwhile;
wp_reset_postdata();
?>
<?php
$year = '';
if (have_posts()) : while (have_posts()) : the_post();
$current_year = get_the_date( 'Y' );
if ( $year != $current_year ) echo '<h4>---' . $current_year . '---</h4>';
?>
<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
</article>
<?php
$year = $current_year;
endwhile; endif; ?>
$year = '';
while ( .... ) :
$current_year = get_the_date( 'Y' );
if ( $year != $current_year ) {
echo '<h4>---' . $current_year . '---</h4>';
// .....
}
$year = $current_year;
endwhile;