いくつかの調査の後、私はそれを行うための解決策を見つけました。
最初に、私は2ページを作成したがhome
とarticles
と呼ばれ、その後、私はSetting -> Reading
を変更:
Front Page
->
home
と
Posts Page
->
articles
。その後、
<?php
if (have_posts()) : while (have_posts()) : the_post();
get_template_part('content', get_post_format());
endwhile; endif;
?>
front-page.php
の内部:
<?php
// the query
$wpb_all_query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 10)); ?>
<?php if ($wpb_all_query->have_posts()) : ?>
<!-- the loop -->
<?php while ($wpb_all_query->have_posts()) : $wpb_all_query->the_post(); ?>
<div class="post">
<div class="col-xs-12 col-lg-6">
<div class="panel panel-default ">
<div class="panel-body">
<div class="col-xs-4">
<a href="<?php the_permalink(); ?>">
<?php if (has_post_thumbnail()) : ?>
<img src="<?php the_post_thumbnail_url(); ?>" alt="">
<?php else: ?>
<img
src="<?php bloginfo('template_directory'); ?>/assets/image/placeholder.jpg"
alt="">
<?php endif; ?>
</a>
</div>
<div class="col-xs-8">
<div class="title">
<a href="<?php the_permalink(); ?>">
<h2><?php the_title(); ?></h2>
</a>
</div>
<div class="content">
<p><?php echo substr(get_the_content(), 0, 320); ?>...</p></div>
<div class="read-more">
<a href="<?php the_permalink(); ?>">Read More</a>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<!-- end of the loop -->
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
最終的にそれは私が望んでいたまさに方法で動作します
はその後、私はindex.php
articles
としてページに次のように置きます。