WordPressとBootstrapで自分のサイトに「articles」というページを作成します。私はそれを探しています:すべて3つの記事(列)、新しい "行"はすべてを分離します。ここでX列の後に自動的に行を作成するWordPress
アンダースコアは次のようになります。これが私のテーマはWordPress用スターターのテーマである行、記事1、記事2、記事3、行、新しい行、第4条、第5条の終わり...
になるだろう
これは完全に動作しますが、コンテンツは無限ループ(無限ループ)で生成されます。
<div class="row">
<?php $i = 1; while(have_posts()) : the_post();?>
<div class="col-sm-4 blog-resume">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header>
<a href="<?php echo get_permalink() ?>">
<div class="featured-image-blog" style="background-image: url('<?php echo get_the_post_thumbnail_url() ?>')"></div>
</a>
</header>
<div class="article-resume text-center">
<h2><a href="<?php echo get_permalink() ?>"><?php echo get_the_title() ?></a></h2>
<p class="posted-on">Posté le <?php echo the_date() ?></p>
<p class="resume-article"><?php echo the_content() ?></p>
</div>
</article>
</div>
<?php if ($i % 3 === 0) { echo '</div><div class="row">'; } ?>
<?php $i++; endwhile; wp_reset_query(); ?>
</div>
は、私はそれはindex.phpのファイルだと思うところcontent.phpのIL呼び出し、ここのindex.phpの内容:ここで
<div class="blog-part">
<div class="container">
<?php
if (have_posts()) :
if (is_home() && ! is_front_page()) : ?>
<header>
<h1 class="text-center"><?php single_post_title(); ?></h1>
</header>
<?php
endif;
/* Start the Loop */
while (have_posts()) : the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part('template-parts/content', get_post_format());
endwhile;
the_posts_navigation();
else :
get_template_part('template-parts/content', 'none');
endif; ?>
</div><!-- container -->
</div><!-- blog-part -->
<?php
get_sidebar();
get_footer();
.blog再開
のCSS.blog-resume {
margin-bottom: 20px;
margin-top: 20px;
}
.blog-resume > article {
background: #fff;
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12), 0 3px 1px -2px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 1px 5px 0 rgba(0,0,0,0.12), 0 3px 1px -2px rgba(0,0,0,0.2);
}
グリッドシステムを使用する必要があります。ブートストラップとCSSグリッドを見てください。 – FluffyKitten
私はブートストラップを使用しているメッセージで指定しました:) – Yann
それを使用するためのドキュメントを調べてください:)あなたがここに投稿する前に、あなたが問題を調査し、自分でコードを書こうとしました。必要な情報はすべてブートストラップのドキュメントにあります。試してみてください*あなたが何か*特定の*にこだわっている場合は、あなたが試したことの概要と関連するコードを含めて戻ってきてください。 [Stack Overflowユーザーの研究努力の程度](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) – FluffyKitten