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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Giustino Borzacchiello
January 12, 2016
Technology
530
1
Share
The WordPress Loop
Giustino Borzacchiello
January 12, 2016
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
85
10* useful WordPress function (* maybe more) - wctrn
justb
0
560
10 Useful WordPress functions (and maybe more)
justb
4
580
MapReduce for clone detection
justb
0
68
Featured posts with thumbnails
justb
0
53
Other Decks in Technology
See All in Technology
AIが自律的に働く時代へ Amazon Quick で実現するAIエージェント紹介
koheiyoshikawa
0
110
AIはハッカーを減らすのか、増やすのか?──現役ホワイトハッカーから見るAI時代のリアル【MEGU-Meet】
cscengineer
PRO
0
210
Expiration of Secure Boot Certificates for vSphere Virtual Machines
mirie_sd
0
110
Anthropic「Long-running a gents」をGeminiで再現してみた
tkikuchi
0
360
VespaのParent Childを用いたフィードパフォーマンスの改善
taking
0
110
AWS Agent Registry の基礎・概要を理解する/aws-agent-registry-intro
ren8k
3
410
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
2.4k
目的ファーストのハーネス設計 ~ハーネスの変更容易性を高めるための優先順位~
gotalab555
8
2.4k
Do Ruby::Box dream of Modular Monolith?
joker1007
1
350
AIでAIをテストする - 音声AIエージェントの品質保証戦略
morix1500
1
140
AgentCore×VPCでの設計パターンn選と勘所
har1101
4
320
Do Vibe Coding ao LLM em Produção para Busca Agêntica - TDC 2026 - Summit IA - São Paulo
jpbonson
3
150
Featured
See All Featured
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
110
The Curious Case for Waylosing
cassininazir
0
320
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
110
Technical Leadership for Architectural Decision Making
baasie
3
340
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Six Lessons from altMBA
skipperchong
29
4.2k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
43k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.9k
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
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/