ループ」は一般的に「WordPressループ」とも呼ばれ、単に「ループ」とも呼ばれます。これは、WordPressサイトの投稿を表示するPHPコードの重要な部分です。
WordPressのループは、WordPressのコードの中で最も重要な部分の一つであり、何らかの形でほとんどのクエリーの中核をなしていると言っても過言ではありません。

インフォグラフィックWordPressループを理解する
ループは、WordPressテーマで投稿のリストをウェブページに表示するために使用されます。
テーマ開発者は、ループ内の各投稿がどのように表示されるかをカスタマイズするために、テンプレートタグを使用して出力をフォーマットすることができます。いくつかのテンプレートタグはWordPressのループ内部でのみ動作し、投稿データをフォーマット、アレンジ、公開するために使用されます。
初心者のためのWordPressループのインフォグラフィックを作成しました。

コード例:WordPressのシンプルなループ
一例をご覧いただきたい。
以下は、WordPressのシンプルなループを形成するためのPHPコードです:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <?php // checks if there are any posts that match the query if (have_posts()) : // If there are posts matching the query then start the loop while ( have_posts() ) : the_post(); // the code between the while loop will be repeated for each post ?> <h2 id= "post-<?php the_ID(); ?>" ><a href= "<?php the_permalink() ?>" rel= "bookmark" title= "Permanent Link to <?php the_title(); ?>" ><?php the_title(); ?></a></h2> <p class = "date-author" >Posted: <?php the_date(); ?> by <?php the_author(); ?></p> <?php the_content(); ?> <p class = "postmetadata" >Filed in: <?php the_category(); ?> | Tagged: <?php the_tags(); ?> | <a href= "<?php comments_link(); ?>" title= "Leave a comment" >Comments</a></p> <?php // Stop the loop when all posts are displayed endwhile ; // If no posts were found else : ?> <p>Sorry no posts matched your criteria.</p> <?php endif ; ?> |
この投稿がWordPressのループについてより深く知っていただく一助となれば幸いです。また、WordPress の便利なヒントやトリック、アイデアに関する関連投稿については、以下の「追加読み物」リストをご覧ください。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.