我正在尝试创建一个自定义搜索结果页面。我希望一次有6篇帖子,然后我要添加一个加载更多的按钮,可以加载更多的6篇帖子,以此类推。我希望页面处于引导网格布局中。每行2个立柱(col-md-6)。使用下面的代码,网页甚至不会显示出来。我是否需要向我的函数添加任何内容。php来实现这一点?有人能帮我吗?提前谢谢。
<?php
get_header();
$the_query = new WP_Query( [
\'posts_per_page\' => 6,
\'paged\' => get_query_var(\'paged\', 1)
] );
if ( $the_query->have_posts() ) { ?>
<div id="ajax">
<?php
while ( $the_query->have_posts() ) { $the_query->the_post(); ?>
<div class="row">
<article <?php post_class( \'col-sm-6 col-md-6\' ); ?>>
<div class="large-front-container">
<?php the_post_thumbnail(\'full\', array(\'class\' => \'large-front-thumbnail\')); ?>
</div>
<div class="front-page-date"><?php echo str_replace(\'mins\', \'minutes\', human_time_diff( get_the_time(\'U\'), current_time(\'timestamp\') ) . \' ago\'); ?></div>
<h2><a class="front-page-post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="front-page-post-excerpt"><?php echo get_the_excerpt(); ?></p>
<div class="front-page-post-info">
<a class="moretext" href="<?php the_permalink(); ?>">Read more</a>
<?php get_template_part( \'front-shop-the-post\' ); ?>
<?php get_template_part( \'share-buttons\' ); ?>
<div class="front-comments"><?php comments_popup_link (\'0\', \'1\', \'%\', \'comment-count\', \'none\'); ?></div>
</div>
</article>
</div>
<?php if(get_query_var(\'paged\') < $the_query->max_num_pages) {
}
}
elseif (!get_query_var(\'paged\') || get_query_var(\'paged\') == \'1\') {
echo \'<p>Sorry, no posts matched your criteria.</p>\';
}
wp_reset_postdata();
get_footer();