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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Giustino Borzacchiello
January 12, 2016
Technology
1
520
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
使って学ぼう MCP (と GitHub Codespaces)
tsubakimoto_s
1
220
失敗できる意思決定とソフトウェアとの正しい歩き方_-_変化と向き合う選択肢/ Designing for Reversible Decisions
soudai
PRO
7
860
Snowflake Night #2 LT
taromatsui_cccmkhd
0
160
パネルディスカッション資料 (at Tableau Now! - 2026-02-26)
yoshitakaarakawa
0
440
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4k
Agent Payments Protocolで実装するAIエージェント間取引
tokio007
0
170
社内ワークショップで終わらせない 業務改善AIエージェント開発
lycorptech_jp
PRO
1
370
Agent Ready になるためにデータ基盤チームが今年やること / How We're Making Our Data Platform Agent-Ready
zaimy
0
170
Claude Codeはレガシー移行でどこまで使えるのか?
ak2ie
0
960
プロダクト開発の品質を守るAIコードレビュー:事例に見る導入ポイント
moongift
PRO
1
500
WBCの解説は生成AIにやらせよう - 生成AIで野球解説者AI Agentを実現する / Baseball Commentator AI Agent for Gemini
shinyorke
PRO
0
110
AI活用を"目的"にしたら、データの本質が見えてきた - Snowflake Intelligence実験記 / chasing-ai-finding-data
pei0804
0
670
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
0
370
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
130
Marketing to machines
jonoalderson
1
5k
The untapped power of vector embeddings
frankvandijk
2
1.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Code Review Best Practice
trishagee
74
20k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
270
Visualization
eitanlees
150
17k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Building Adaptive Systems
keathley
44
2.9k
Agile that works and the tools we love
rasmusluckow
331
21k
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/