Я оставляю новое для разработки темы WordPress. Я пытаюсь показать только первые две последние сообщения на моей домашней странице, но независимо от того, что я делаю, код всегда проходит через все сообщения. Любая помощь приветствуется.Как показывать только первые два сообщения?
index.php:
<?php get_header(); ?>
<?php $args = array(
'numberposts' => 10,
'offset' => 0,
'category' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'draft, publish, future, pending, private',
'suppress_filters' => true);
$recent_posts = wp_get_recent_posts($args);
?>
<?php if(have_posts()) :
if(have_posts()) : the_post(); ?>
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-4">
<h2><a href="<?php the_permalink(); ?>"><?php the_title() ?></a></h2>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('banner-image') ?></a>
</div>
<div class="col-md-4">
<h2><a href="<?php the_permalink(); ?>"><?php the_title() ?></a></h2>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('banner-image') ?></a>
</div>
<div class="col-md-4">
<div class="pull-right marTop20">
<h4>Most recent posts</h4>
<?php $recent_posts = wp_get_recent_posts($args); ?>
<?php foreach($recent_posts as $recent){ ?>
<ul class="list-unstyled">
<?php echo '<li class="list-item"><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"].'</a> </li> '; ?>
</ul>
<?php } ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<p><?php echo get_the_excerpt(); ?>
<a href="<?php the_permalink(); ?>">Read more</a></p>
</div>
<div class="col-md-4">
<p><?php echo get_the_excerpt(); ?>
<a href="<?php the_permalink(); ?>">Read more</a></p>
</div>
</div>
</div>
</div>
<?php
endif;
endif;
?>
<?php get_footer(); ?>
Вы пытались установить 2 в ' 'numberposts'' параметра? –
@bhelmet Это для боковой панели, это первые 10 названий сообщений. Теперь я хочу показать первые два сообщения, а также – Raymond