<?php
$args = array(
'numberposts' => 4,
'category' => 18,
'post_status' => 'publish',
);
$result = wp_get_recent_posts( $args );
foreach( $result as $p ){
?>
<article>
<span></span>
<h4><?php echo $p['post_title'] ?></h4>
<p></p>
<a href="<?php echo get_permalink($p['ID']) ?>" class="research-link"></a>
</article>
<?php
}
?>
<?php
$args = array(
'numberposts' => 4,
'category' => 18,
'post_status' => 'publish',
);
$result = wp_get_recent_posts( $args );
foreach( $result as $post ){
setup_postdata( $post );
?>
<article>
<span><?php the_date('j F Y') ?></span>
<h4><?php the_title() ?></h4>
<?php the_excerpt() ?>
<a href="<?php the_permalink() ?>" class="research-link"></a>
</article>
<?php
}
wp_reset_postdata();
?>
<?php // задаем нужные нам критерии выборки данных из БД
$args = array(
'numberposts' => 4,
'category' => 18,
'post_status' => 'publish',
);
$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(); ?>>
<div class="entry">
<div class="entry__part entry__header">
<h2 class="entry__title"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
</div>
<div class="entry__part entry__meta">
<ul class="meta-list meta-list_inline">
<li class="meta-list__item meta-list__item_autor">
<?php echo '<a class="meta-list__link" href="' . get_author_posts_url( get_the_author_meta( 'ID' ) ) . '">' . get_the_author() . '</a>'; ?>
</li>
<li class="meta-list__item meta-list__item_date">
<?php echo '<time class="meta-list__date meta-list__date-published" datetime="' . get_the_date( 'Y-m-d\TH:i:sP' ) . '">' . get_the_date( 'j M, Y' ) . '</time>'; ?>
</li>
<li class="meta-list__item meta-list__item_category">
<?php echo get_the_category_list( ', ' ); ?>
</li>
<li class="meta-list__item meta-list__item_comments-count">
<?php echo '<a class="meta-list__link" href="' . get_comments_link() . '" rel="bookmark">' . __( 'Comments', 'skill' ) . ': ' . get_comments_number() . '</a>'; ?>
</li>
</ul>
</div>
<div class="entry__part entry__excerpt">
<?php the_excerpt(); ?>
</div>
<div class="entry__part entry__link-more">
<a class="link link_more" href="<?php the_permalink() ?>"><?php _e( 'Read more', 'skill' ); ?></a>
</div>
</div>
</article>
<?php }
} else {
// Постов не найдено
}
// Возвращаем оригинальные данные поста. Сбрасываем $post.
wp_reset_postdata();