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
Giustino Borzacchiello
January 12, 2016
Technology
540
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The WordPress Loop
Giustino Borzacchiello
January 12, 2016
More Decks by Giustino Borzacchiello
See All by Giustino Borzacchiello
Cos'è Gutenberg?
justb
1
250
The WordPress Economy
justb
0
270
Vagrant: why and how
justb
0
91
10* useful WordPress function (* maybe more) - wctrn
justb
0
580
10 Useful WordPress functions (and maybe more)
justb
4
590
MapReduce for clone detection
justb
0
71
Featured posts with thumbnails
justb
0
55
Other Decks in Technology
See All in Technology
Comment regagner la souveraineté de vos données tout en étant payé grâce à Nostr !
rlifchitz
0
220
【FinOps】データドリブンな意思決定を目指して
z63d
2
480
起点・思考・出力で分解する 〜PM業務の自動化設計〜
kazu_kichi_67
2
1.1k
GitHub Copilot運用のリアル ~AI Credit時代にどう向き合うか~
takafumisu2uk1
0
480
感情と身体を置き去りにしない、エンジニアの生きのこり方 ──いまから、ここから「自分の状態」を扱うという選択
saorimurooka
0
360
“詰む”前に仕組みを作れ 〜技術の波に溺れないためのキャッチアップ術〜
takasyou
7
4.2k
When Platform Engineering Meets GenAI
sucitw
0
200
[AWS Summit Japan 2026]迷っているあなたへ_小さな一歩が、やがて自分を助けてくれる
sh_fk2
2
430
トークン最適化のためのユーザーストーリー分析 / User Story Analysis for Token Optimization
oomatomo
0
120
打造你的 AI 工作流:Agent Skill + MCP 實戰工作坊
appleboy
0
140
FPC(フレキシブル)基板にZephyr実装してみた。
iotengineer22
0
180
クラウドファンディング版StackChan 3体(4体)をインタラクティブな体験型作品にして展示もした話 / スタックチャンお誕生日会2026
you
PRO
0
200
Featured
See All Featured
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
Music & Morning Musume
bryan
47
7.2k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
66
55k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
870
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
180
Deep Space Network (abreviated)
tonyrice
0
210
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
260
Writing Fast Ruby
sferik
630
63k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
620
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
440
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/