【发布时间】:2019-07-18 03:12:58
【问题描述】:
我是 WordPress 的新手,正在尝试对网站进行更改。
现在该网站显示无限的帖子和文章。我想将其更改为仅一起显示 5 篇文章和帖子。
我不知道如何更改它,因为它也连接到按钮。当您单击此按钮时,它仍会显示所有帖子和文章。
有人知道我该如何继续前进吗?
最好的问候,
<?php get_header();?>
<?php get_template_part( 'templates/top', 'section' ); ?>
<section class="blog-section">
<div class="row">
<?php get_sidebar( 'blog' ); ?>
<main id="main" class="blog-section__main small-12 large-8 medium-6 small-order-1 medium-order-2 columns" role="main">
<div class="news-feed">
<h2 class="news-feed__heading h3"><?php echo __('Articles and blog posts'); ?></h2>
<?php
// Fetch news posts
$posts = get_news_posts([
'posts_per_page' => NEWS_POSTS_PER_PAGE
]);
if ($posts->have_posts()) : while ($posts->have_posts()) : $posts->the_post();
get_template_part( 'templates/loop', 'news' );
endwhile;
wp_reset_postdata();
?>
</div>
<?php
if( $posts->found_posts > $posts->post_count )
echo '<a href="#" data-offset="' . NEWS_POSTS_PER_PAGE . '" id="load-more-news" class="button button--primary"> <div class="news-button">' . __('Load more') . '</div> </button>'
?>
<!-- <?php page_navi(); ?> -->
<?php else : ?>
<?php get_template_part( 'templates/content', 'missing' ); ?>
<?php endif; ?>
</main> <!-- end #main -->
</div> <!-- end .row -->
</section> <!-- end .blog -->
<?php
global $post;
$qo = get_queried_object();
$post->ID = $qo->ID;
get_template_part('templates/flexible-content');
?>
<?php get_footer(); ?>
【问题讨论】: