SlideShare uma empresa Scribd logo
1 de 17
Welcome

         CUSTOMIZING THE CUSTOM LOOP




Code: http://github.com/jmarx/Wordcamp-NYC-2012
Meet the guys
Alexander Sapountzis       Jeff Marx
•  Worked with             •  Worked with
   WordPress for 2            WordPress for 7 years
   Years                   •  Worked a Gannet
•  Worked at Bloomberg        Newspapers
   Businessweek            •  Snappy Dresser
•  He's the one with the
   beard
What is CBS Local?
Network of local sites for news and media,
 consolidating CBS' media content
• Radio
• TV
• News
• Original Content

www.cbslocal.com
We use WordPress!
After the five-minute install
                         •
                         •    You get a cool theme

                         •
                         •
                              Single Column
                              Sidebar
                              ...but it's boring



                        We need to customize this so it's cool!
What comes next?
•   Featured Posts
•   Category Boxes
•   Cool stuff
•   Not boring!
How do we do this?

(PAY ATTENTION, THIS WILL BE ON THE
               TEST)
The Global Query
•   Runs once on every page
•   Returns all relevant posts based on params
    o Home Page Query returns all posts
    o Category Page Query returns all for that category
    o Single Post Page Query returns a single, lonely post

•   Global query feeds default loop
    o   default loop is hard coded on theme template files and
        contains post information from the global query
•   This comes built into WordPress
WordPress does all this for free
...what's the problem? Why bother with custom
   loops?

Because you may need to:
• Categorize content
• use Custom Post Types
• not have a boring site
Introduce The Loops
•   query_posts()
•   WP_Query
•   get_posts()

Each is used in different ways, but you really only
 need one; WP_Query
query_posts()
•   Modifies the Global Query (that's bad)
•   Can cause unpredictable behavior
•   Will very likely be removed from WordPress (we
    hope soon)
•   Ignore tutorials that use this

Remember: using query_posts() is like trying to
 hammer a nail in with your forehead; painful and
 messy
get_posts()
•   Safer but not ideal
•   Limited - Not as powerful or useful
•   Some template tags are not included

This is like the little brother of WP_Query. It uses
 WP_Query behind the scenes, but hides quite a bit
 from you
WP_Query
•   Returns everything you need
•   Template tags will work
•   Plays nice with the Global Query
•   High in fiber

query_posts() and get_posts() actually use this
 internally, but do other things that you don't want.
 Cut out the middle man!
Standard Loop
Examples of the standard loop (before we make it all
 fancy)

https://github.com/jmarx/Wordcamp-NYC-
  2012/blob/master/twentyten_jeff/standard-
  loop.php
Custom Loop Examples
 Homepage:
  https://github.com/jmarx/Wordcamp-NYC-
  2012/blob/master/twentyten_jeff/loop-index.php
 Sidebar:
  https://github.com/jmarx/Wordcamp-NYC-
  2012/blob/master/twentyten_jeff/sidebar.php
 Page
  https://github.com/jmarx/Wordcamp-NYC-
  2012/blob/master/twentyten_jeff/page_dc.php
Performance Gotchas
•   Use caching and transients to improve performance
•   Limits load by minimizing database calls
•   Don't need too many loops on your site
Got Questions?
@jeffreymarx
@asapountzis

Code Samples:
https://github.com/jmarx/Wordcamp-NYC-2012

Mais conteúdo relacionado

Mais procurados

Blogs and RSS – Trawling the Internet for Meaning
Blogs and RSS – Trawling the Internet for MeaningBlogs and RSS – Trawling the Internet for Meaning
Blogs and RSS – Trawling the Internet for MeaningESUG
 
Blogging with drupal
Blogging with drupalBlogging with drupal
Blogging with drupalChris Ward
 
LeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than developmentLeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than developmentJohn McCaffrey
 
Unless It Was a Digital Dog, No One Ate Your Homework (Diigo)
Unless It Was a Digital Dog, No One Ate Your Homework (Diigo)Unless It Was a Digital Dog, No One Ate Your Homework (Diigo)
Unless It Was a Digital Dog, No One Ate Your Homework (Diigo)Lisa Sjogren
 
Graham Lavender on blogs and Twitter at John Abbott 2010
Graham Lavender on blogs and Twitter at John Abbott 2010Graham Lavender on blogs and Twitter at John Abbott 2010
Graham Lavender on blogs and Twitter at John Abbott 2010guybrariang
 
Syndication in WordPress with RSS Scott Huntley
Syndication in WordPress with RSS  Scott HuntleySyndication in WordPress with RSS  Scott Huntley
Syndication in WordPress with RSS Scott HuntleyePortfolios Australia
 
Becoming a more productive Rails Developer
Becoming a more productive Rails DeveloperBecoming a more productive Rails Developer
Becoming a more productive Rails DeveloperJohn McCaffrey
 
The Non-Designer’s Guide to WordPress (Making Your Site Look Awesome)
The Non-Designer’s Guide to WordPress (Making Your Site Look Awesome)The Non-Designer’s Guide to WordPress (Making Your Site Look Awesome)
The Non-Designer’s Guide to WordPress (Making Your Site Look Awesome)Mykl Roventine
 
Accessible content
Accessible contentAccessible content
Accessible contentMaja Benke
 
Social dev camp_2011
Social dev camp_2011Social dev camp_2011
Social dev camp_2011Craig Ulliott
 
The Non-designer's Guide to WordPress (Making Your Site Awesome)
The Non-designer's Guide to WordPress (Making Your Site Awesome)The Non-designer's Guide to WordPress (Making Your Site Awesome)
The Non-designer's Guide to WordPress (Making Your Site Awesome)Mykl Roventine
 
How to Build Great Product – use blogging
How to Build Great Product – use bloggingHow to Build Great Product – use blogging
How to Build Great Product – use bloggingBhasker Vijaykumar Bhatt
 
Adobe Education Blog: Get Writing!
Adobe Education Blog: Get Writing!Adobe Education Blog: Get Writing!
Adobe Education Blog: Get Writing!Joseph Labrecque
 
Managing Multiple Authors with WordPress
Managing Multiple Authors with WordPressManaging Multiple Authors with WordPress
Managing Multiple Authors with WordPressAl Davis
 
Tumblrtail - Tumblr Developer's Meetup jp 2011
Tumblrtail - Tumblr Developer's Meetup jp 2011Tumblrtail - Tumblr Developer's Meetup jp 2011
Tumblrtail - Tumblr Developer's Meetup jp 2011Naomoto Niwayama
 

Mais procurados (18)

Blogs and RSS – Trawling the Internet for Meaning
Blogs and RSS – Trawling the Internet for MeaningBlogs and RSS – Trawling the Internet for Meaning
Blogs and RSS – Trawling the Internet for Meaning
 
Blogging with drupal
Blogging with drupalBlogging with drupal
Blogging with drupal
 
LeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than developmentLeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than development
 
Unless It Was a Digital Dog, No One Ate Your Homework (Diigo)
Unless It Was a Digital Dog, No One Ate Your Homework (Diigo)Unless It Was a Digital Dog, No One Ate Your Homework (Diigo)
Unless It Was a Digital Dog, No One Ate Your Homework (Diigo)
 
Graham Lavender on blogs and Twitter at John Abbott 2010
Graham Lavender on blogs and Twitter at John Abbott 2010Graham Lavender on blogs and Twitter at John Abbott 2010
Graham Lavender on blogs and Twitter at John Abbott 2010
 
Syndication in WordPress with RSS Scott Huntley
Syndication in WordPress with RSS  Scott HuntleySyndication in WordPress with RSS  Scott Huntley
Syndication in WordPress with RSS Scott Huntley
 
Becoming a more productive Rails Developer
Becoming a more productive Rails DeveloperBecoming a more productive Rails Developer
Becoming a more productive Rails Developer
 
The Non-Designer’s Guide to WordPress (Making Your Site Look Awesome)
The Non-Designer’s Guide to WordPress (Making Your Site Look Awesome)The Non-Designer’s Guide to WordPress (Making Your Site Look Awesome)
The Non-Designer’s Guide to WordPress (Making Your Site Look Awesome)
 
Accessible content
Accessible contentAccessible content
Accessible content
 
Blogging 101
Blogging 101Blogging 101
Blogging 101
 
Social dev camp_2011
Social dev camp_2011Social dev camp_2011
Social dev camp_2011
 
Social media
Social mediaSocial media
Social media
 
The Non-designer's Guide to WordPress (Making Your Site Awesome)
The Non-designer's Guide to WordPress (Making Your Site Awesome)The Non-designer's Guide to WordPress (Making Your Site Awesome)
The Non-designer's Guide to WordPress (Making Your Site Awesome)
 
How to Build Great Product – use blogging
How to Build Great Product – use bloggingHow to Build Great Product – use blogging
How to Build Great Product – use blogging
 
Adobe Education Blog: Get Writing!
Adobe Education Blog: Get Writing!Adobe Education Blog: Get Writing!
Adobe Education Blog: Get Writing!
 
Managing Multiple Authors with WordPress
Managing Multiple Authors with WordPressManaging Multiple Authors with WordPress
Managing Multiple Authors with WordPress
 
Blogging pains
Blogging painsBlogging pains
Blogging pains
 
Tumblrtail - Tumblr Developer's Meetup jp 2011
Tumblrtail - Tumblr Developer's Meetup jp 2011Tumblrtail - Tumblr Developer's Meetup jp 2011
Tumblrtail - Tumblr Developer's Meetup jp 2011
 

Semelhante a Customizing the custom loop wordcamp 2012

Building a Simple Theme Framework
Building a Simple Theme FrameworkBuilding a Simple Theme Framework
Building a Simple Theme FrameworkJoe Casabona
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talkReuven Lerner
 
PEPY Wordpress workshop-01
PEPY Wordpress workshop-01PEPY Wordpress workshop-01
PEPY Wordpress workshop-01Wei Peng
 
6 reasons Jubilee could be a Rubyist's new best friend
6 reasons Jubilee could be a Rubyist's new best friend6 reasons Jubilee could be a Rubyist's new best friend
6 reasons Jubilee could be a Rubyist's new best friendForrest Chang
 
Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008Eric D.
 
Theming moodle technical
Theming moodle   technicalTheming moodle   technical
Theming moodle technicalAlex Walker
 
Taking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the LimitTaking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the LimitJosh Guffey
 
"Problems and solutions with generative and non-generative AI models deployme...
"Problems and solutions with generative and non-generative AI models deployme..."Problems and solutions with generative and non-generative AI models deployme...
"Problems and solutions with generative and non-generative AI models deployme...Fwdays
 
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Mike Schinkel
 
A tale of 3 databases
A tale of 3 databasesA tale of 3 databases
A tale of 3 databasesChris Skardon
 
Keeping MongoDB Data Safe
Keeping MongoDB Data SafeKeeping MongoDB Data Safe
Keeping MongoDB Data SafeTony Tam
 
Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06jimbojsb
 
WebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D EngineWebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D Engineaerotwist
 
WordPress Themes Demystified
WordPress Themes DemystifiedWordPress Themes Demystified
WordPress Themes DemystifiedChris Burgess
 
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Mozaic Works
 
Why I will never write JavaScript ever again*
Why I will never write JavaScript ever again*Why I will never write JavaScript ever again*
Why I will never write JavaScript ever again*The Wolff
 

Semelhante a Customizing the custom loop wordcamp 2012 (20)

Building a Simple Theme Framework
Building a Simple Theme FrameworkBuilding a Simple Theme Framework
Building a Simple Theme Framework
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talk
 
PEPY Wordpress workshop-01
PEPY Wordpress workshop-01PEPY Wordpress workshop-01
PEPY Wordpress workshop-01
 
6 reasons Jubilee could be a Rubyist's new best friend
6 reasons Jubilee could be a Rubyist's new best friend6 reasons Jubilee could be a Rubyist's new best friend
6 reasons Jubilee could be a Rubyist's new best friend
 
Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008
 
Theming moodle technical
Theming moodle   technicalTheming moodle   technical
Theming moodle technical
 
Taking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the LimitTaking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the Limit
 
"Problems and solutions with generative and non-generative AI models deployme...
"Problems and solutions with generative and non-generative AI models deployme..."Problems and solutions with generative and non-generative AI models deployme...
"Problems and solutions with generative and non-generative AI models deployme...
 
Working with WordPress themes
Working with WordPress themesWorking with WordPress themes
Working with WordPress themes
 
Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)Developing Complex WordPress Sites without Fear of Failure (with MVC)
Developing Complex WordPress Sites without Fear of Failure (with MVC)
 
A tale of 3 databases
A tale of 3 databasesA tale of 3 databases
A tale of 3 databases
 
Keeping MongoDB Data Safe
Keeping MongoDB Data SafeKeeping MongoDB Data Safe
Keeping MongoDB Data Safe
 
Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06
 
onGameStart
onGameStartonGameStart
onGameStart
 
WebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D EngineWebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D Engine
 
WordPress Themes Demystified
WordPress Themes DemystifiedWordPress Themes Demystified
WordPress Themes Demystified
 
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
 
Design todevelop
Design todevelopDesign todevelop
Design todevelop
 
Forget The ORM!
Forget The ORM!Forget The ORM!
Forget The ORM!
 
Why I will never write JavaScript ever again*
Why I will never write JavaScript ever again*Why I will never write JavaScript ever again*
Why I will never write JavaScript ever again*
 

Último

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Último (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

Customizing the custom loop wordcamp 2012

  • 1. Welcome CUSTOMIZING THE CUSTOM LOOP Code: http://github.com/jmarx/Wordcamp-NYC-2012
  • 2. Meet the guys Alexander Sapountzis Jeff Marx • Worked with • Worked with WordPress for 2 WordPress for 7 years Years • Worked a Gannet • Worked at Bloomberg Newspapers Businessweek • Snappy Dresser • He's the one with the beard
  • 3. What is CBS Local? Network of local sites for news and media, consolidating CBS' media content • Radio • TV • News • Original Content www.cbslocal.com
  • 5. After the five-minute install • • You get a cool theme • • Single Column Sidebar ...but it's boring We need to customize this so it's cool!
  • 6. What comes next? • Featured Posts • Category Boxes • Cool stuff • Not boring!
  • 7. How do we do this? (PAY ATTENTION, THIS WILL BE ON THE TEST)
  • 8. The Global Query • Runs once on every page • Returns all relevant posts based on params o Home Page Query returns all posts o Category Page Query returns all for that category o Single Post Page Query returns a single, lonely post • Global query feeds default loop o default loop is hard coded on theme template files and contains post information from the global query • This comes built into WordPress
  • 9. WordPress does all this for free ...what's the problem? Why bother with custom loops? Because you may need to: • Categorize content • use Custom Post Types • not have a boring site
  • 10. Introduce The Loops • query_posts() • WP_Query • get_posts() Each is used in different ways, but you really only need one; WP_Query
  • 11. query_posts() • Modifies the Global Query (that's bad) • Can cause unpredictable behavior • Will very likely be removed from WordPress (we hope soon) • Ignore tutorials that use this Remember: using query_posts() is like trying to hammer a nail in with your forehead; painful and messy
  • 12. get_posts() • Safer but not ideal • Limited - Not as powerful or useful • Some template tags are not included This is like the little brother of WP_Query. It uses WP_Query behind the scenes, but hides quite a bit from you
  • 13. WP_Query • Returns everything you need • Template tags will work • Plays nice with the Global Query • High in fiber query_posts() and get_posts() actually use this internally, but do other things that you don't want. Cut out the middle man!
  • 14. Standard Loop Examples of the standard loop (before we make it all fancy) https://github.com/jmarx/Wordcamp-NYC- 2012/blob/master/twentyten_jeff/standard- loop.php
  • 15. Custom Loop Examples  Homepage: https://github.com/jmarx/Wordcamp-NYC- 2012/blob/master/twentyten_jeff/loop-index.php  Sidebar: https://github.com/jmarx/Wordcamp-NYC- 2012/blob/master/twentyten_jeff/sidebar.php  Page https://github.com/jmarx/Wordcamp-NYC- 2012/blob/master/twentyten_jeff/page_dc.php
  • 16. Performance Gotchas • Use caching and transients to improve performance • Limits load by minimizing database calls • Don't need too many loops on your site