Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The WordPress Loop
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Giustino Borzacchiello
January 12, 2016
Technology
1
530
The WordPress Loop
Giustino Borzacchiello
January 12, 2016
Tweet
Share
More Decks by Giustino Borzacchiello
See All by Giustino Borzacchiello
Cos'è Gutenberg?
justb
1
240
The WordPress Economy
justb
0
260
Vagrant: why and how
justb
0
84
10* useful WordPress function (* maybe more) - wctrn
justb
0
560
10 Useful WordPress functions (and maybe more)
justb
4
570
MapReduce for clone detection
justb
0
67
Featured posts with thumbnails
justb
0
49
Other Decks in Technology
See All in Technology
JAWS Days 2026 楽しく学ぼう! 認証認可 入門/20260307-jaws-days-novice-lane-auth
opelab
11
2k
脳内メモリ、思ったより揮発性だった
koutorino
0
330
Abuse report だけじゃない。AWS から緊急連絡が来る状況とは?昨今の攻撃や被害の事例の紹介と備えておきたい考え方について
kazzpapa3
1
620
Dr. Werner Vogelsの14年のキーノートから紐解くエンジニアリング組織への処方箋@JAWS DAYS 2026
p0n
1
130
楽しく学ぼう!コミュニティ入門 AWSと人が つむいできたストーリー
hiroramos4
PRO
1
190
IBM Bobを使って、PostgreSQLのToDoアプリをDb2へ変換してみよう/202603_Dojo_Bob
mayumihirano
1
330
20260311 ビジネスSWG活動報告(デジタルアイデンティティ人材育成推進WG Ph2 活動報告会)
oidfj
0
300
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
8
7.2k
AI時代の「本当の」ハイブリッドクラウド — エージェントが実現した、あの頃の夢
ebibibi
0
110
OCHaCafe S11 #2 コンテナ時代の次の一手:Wasm 最前線
oracle4engineer
PRO
2
120
NewSQL_ ストレージ分離と分散合意を用いたスケーラブルアーキテクチャ
hacomono
PRO
4
320
アーキテクチャモダナイゼーションを実現する組織
satohjohn
1
610
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
463
34k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
210
How to build a perfect <img>
jonoalderson
1
5.2k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
How to Think Like a Performance Engineer
csswizardry
28
2.5k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
Technical Leadership for Architectural Decision Making
baasie
3
290
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
76
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
64
53k
30 Presentation Tips
portentint
PRO
1
250
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Fireside Chat
paigeccino
42
3.8k
Transcript
The WordPress Loop Giustino Borzacchiello / WordPress Meetup Milano -
January 2016
The standard Loop
The standard Loop What’s The Loop?
The standard Loop “The Loop is PHP code used by
WordPress to display posts.” https://codex.wordpress.org/The_Loop
The standard Loop “The Loop is PHP code used by
WordPress to display posts.” https://codex.wordpress.org/The_Loop
The standard Loop “The Loop is PHP code used by
WordPress to display posts.” https://codex.wordpress.org/The_Loop
The standard Loop Post list
The standard Loop Single post/page
The standard Loop “Mullet” loop
The standard Loop Random post widget
The standard Loop Related posts
The standard Loop The Loop breakdown
<?php if ( have_posts() ): while ( have_posts() ): the_post();
// Single post endwhile; else: // No post found endif;
<?php if ( have_posts() ): while ( have_posts() ): the_post();
// Single post endwhile; else: // No post found endif;
<?php if ( have_posts() ): while ( have_posts() ): the_post();
// Single post endwhile; else: // No post found endif;
<?php if ( have_posts() ): while ( have_posts() ): the_post();
// Single post endwhile; else: // No post found endif;
... while ( have_posts() ): the_post(); <h2><?php the_title(); ?></h2> <?php
the_excerpt(); ?> endwhile; else: // No post found endif;
... while ( have_posts() ): the_post(); <h2><?php the_title(); ?></h2> <?php
the_excerpt(); ?> endwhile; else: // No post found endif; Template tags
<?php if ( have_posts() ): while ( have_posts() ): the_post();
// Single post endwhile; else: // No post found endif;
<?php if ( have_posts() ): while ( have_posts() ): the_post();
// Single post endwhile; else: // No post found endif;
The standard Loop Single Loop
if ( have_posts() ): while ( have_posts() ): the_post(); <h2><?php
the_title(); ?></h2> <?php the_content(); ?> endwhile; endif;
The standard Loop “Mullet” Loop
The standard Loop 1 2 3 4 5
<?php if ( have_posts() ): $count = 0; while (
have_posts() ): the_post(); if( 0 === $count ) { // first post } else { // other posts } $count += 1; endwhile; endif;
The standard Loop Random posts Loop
<?php $rand_query = new WP_Query(['orderby' => 'rand']); if ( $rand_query->have_posts()
): while ( $rand_query->have_posts() ): $rand_query->the_post(); the_title(); endwhile; endif; wp_reset_postdata();
<?php $rand_query = new WP_Query(['orderby' => 'rand']); if ( $rand_query->have_posts()
): while ( $rand_query->have_posts() ): $rand_query->the_post(); the_title(); endwhile; endif; wp_reset_postdata();
The standard Loop Useful references
The standard Loop The loop and template tags https://developer.wordpress.org/themes/basics/the-loop/ https://codex.wordpress.org/The_Loop
https://codex.wordpress.org/The_Loop_in_Action
The standard Loop Try to find and understand the loop
in this theme https://github.com/WordPress/twentysixteen
The standard Loop How does WordPress find what posts to
show? https://developer.wordpress.org/themes/basics/template-hierarchy/
The standard Loop WP_Query https://codex.wordpress.org/Class_Reference/WP_Query
The standard Loop thank you @jubstuff borzacchiello.it
The standard Loop Extra: related posts loop
if ( have_posts() ): while ( have_posts() ): the_post(); //
EXERCISE! Insert here template tags $rel_query = new WP_Query([ 'category__in' => wp_get_post_categories($post->ID), 'post__not_in' => [$post->ID], 'posts_per_page' => 3, ]); // EXERCISE! Insert here $rel_query loop! endwhile; endif;
Images https://www.flickr.com/photos/nkphillips/2984667077/ https://www.flickr.com/photos/jeremybrooks/2214481087/ https://www.flickr.com/photos/benjaminbeard/5642453196/ https://www.flickr.com/photos/jpestana/16315778523/ https://www.flickr.com/photos/xroper7/19998325086/ https://www.flickr.com/photos/katsrcool/16912193533/ https://www.flickr.com/photos/15609463@N03/9848807935/ https://www.flickr.com/photos/adamfowler/4841559945/ https://www.flickr.com/photos/donald_gunn/15340138404/
https://www.flickr.com/photos/trevira1/8218299403/