SlideShare a Scribd company logo
1 of 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 Years     WordPress for 7 years
•Worked at Bloomberg     • Worked at Gannett
 Businessweek              Newspapers
•He's the one with the   • Not the guy from the
 beard                     Sopranos (even though
                           he looks like him)
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
    http://codex.wordpress.org/Class_Reference/WP_Query


     query_posts() and get_posts() actually use this
     internally, but either do other things that you
     don't want or won’t give you what you 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
Custom Loop Examples

 Homepage:
  https://
  github.com/jmarx/Wordcamp-NYC-2012/blob/master/twenty
 Sidebar:
  https://
  github.com/jmarx/Wordcamp-NYC-2012/blob/master/twenty
 Page
  https://
  github.com/jmarx/Wordcamp-NYC-2012/blob/master/twenty
Performance Gotchas

•   Use caching and transients to improve performance
•   Limits load by minimizing database calls
•   Always cache your site when using custom loops!



Links:
http://wordpress.org/extend/plugins/wp-super-cache/
http://wordpress.org/extend/plugins/w3-total-cache/
http://codex.wordpress.org/Transients_API
Got Questions?

@jeffreymarx
@asapountzis

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

More Related Content

What's hot

Theme Development: From an idea to getting approved to wordpress.org
Theme Development: From an idea to getting approved to wordpress.orgTheme Development: From an idea to getting approved to wordpress.org
Theme Development: From an idea to getting approved to wordpress.orgThemeHorse
 
Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)Daniel Friedman
 
Riding IronRuby on Rails
Riding IronRuby on RailsRiding IronRuby on Rails
Riding IronRuby on RailsShay Friedman
 
LeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than developmentLeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than developmentJohn McCaffrey
 
AWS Users Meetup April 2015
AWS Users Meetup April 2015AWS Users Meetup April 2015
AWS Users Meetup April 2015Jervin Real
 
Jekyll and MrBlog
Jekyll and MrBlogJekyll and MrBlog
Jekyll and MrBlogNola Stowe
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6Rob Eisenberg
 
Thing to love in Clojure
Thing to love in ClojureThing to love in Clojure
Thing to love in ClojureJiří Knesl
 
WordPress Custom Post Types
WordPress Custom Post TypesWordPress Custom Post Types
WordPress Custom Post TypesMark Jaquith
 
CatalystX::SimpleLogin
CatalystX::SimpleLoginCatalystX::SimpleLogin
CatalystX::SimpleLoginTomas Doran
 
Airbnb Java Script style guide
Airbnb Java Script style guideAirbnb Java Script style guide
Airbnb Java Script style guideAhmed Elbassel
 
Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06jimbojsb
 
Playing with playgrounds
Playing with playgroundsPlaying with playgrounds
Playing with playgroundsEurico Doirado
 
Acts 6 5 this proposal pleased the whole power point church sermon
Acts 6 5 this proposal pleased the whole power point church sermonActs 6 5 this proposal pleased the whole power point church sermon
Acts 6 5 this proposal pleased the whole power point church sermonPowerPoint_Sermons
 
Site Builders: Let's clean up our UIs!
Site Builders: Let's clean up our UIs!Site Builders: Let's clean up our UIs!
Site Builders: Let's clean up our UIs!cherryhillco
 
URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5jakemallory
 
Drupal: Mitigating Risk with Multiple Content Creators
Drupal: Mitigating Risk with Multiple Content CreatorsDrupal: Mitigating Risk with Multiple Content Creators
Drupal: Mitigating Risk with Multiple Content CreatorsiFactory
 

What's hot (20)

Theme Development: From an idea to getting approved to wordpress.org
Theme Development: From an idea to getting approved to wordpress.orgTheme Development: From an idea to getting approved to wordpress.org
Theme Development: From an idea to getting approved to wordpress.org
 
Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)
 
Riding IronRuby on Rails
Riding IronRuby on RailsRiding IronRuby on Rails
Riding IronRuby on Rails
 
LeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than developmentLeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than development
 
AWS Users Meetup April 2015
AWS Users Meetup April 2015AWS Users Meetup April 2015
AWS Users Meetup April 2015
 
Jekyll and MrBlog
Jekyll and MrBlogJekyll and MrBlog
Jekyll and MrBlog
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
 
Thing to love in Clojure
Thing to love in ClojureThing to love in Clojure
Thing to love in Clojure
 
Construct Unified
Construct UnifiedConstruct Unified
Construct Unified
 
WordPress Custom Post Types
WordPress Custom Post TypesWordPress Custom Post Types
WordPress Custom Post Types
 
ASP.NET MVC
ASP.NET MVCASP.NET MVC
ASP.NET MVC
 
CatalystX::SimpleLogin
CatalystX::SimpleLoginCatalystX::SimpleLogin
CatalystX::SimpleLogin
 
Component-first Applications
Component-first ApplicationsComponent-first Applications
Component-first Applications
 
Airbnb Java Script style guide
Airbnb Java Script style guideAirbnb Java Script style guide
Airbnb Java Script style guide
 
Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06
 
Playing with playgrounds
Playing with playgroundsPlaying with playgrounds
Playing with playgrounds
 
Acts 6 5 this proposal pleased the whole power point church sermon
Acts 6 5 this proposal pleased the whole power point church sermonActs 6 5 this proposal pleased the whole power point church sermon
Acts 6 5 this proposal pleased the whole power point church sermon
 
Site Builders: Let's clean up our UIs!
Site Builders: Let's clean up our UIs!Site Builders: Let's clean up our UIs!
Site Builders: Let's clean up our UIs!
 
URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5URUG Ruby on Rails Workshop - Sesssion 5
URUG Ruby on Rails Workshop - Sesssion 5
 
Drupal: Mitigating Risk with Multiple Content Creators
Drupal: Mitigating Risk with Multiple Content CreatorsDrupal: Mitigating Risk with Multiple Content Creators
Drupal: Mitigating Risk with Multiple Content Creators
 

Viewers also liked

Firstborn child theme word camp presentation - atlanta 2013
Firstborn child theme   word camp presentation - atlanta 2013Firstborn child theme   word camp presentation - atlanta 2013
Firstborn child theme word camp presentation - atlanta 2013Evan Mullins
 
Google loves WordPress - Blogging For SEO WordCamp NYC 2012
Google loves WordPress - Blogging For SEO WordCamp NYC 2012Google loves WordPress - Blogging For SEO WordCamp NYC 2012
Google loves WordPress - Blogging For SEO WordCamp NYC 2012Organical - The SEO Experts
 
Killer Docs for Killer Devs
Killer Docs for Killer DevsKiller Docs for Killer Devs
Killer Docs for Killer Devsspmckeown
 
Developing digital marketing into your WordPress
Developing digital marketing into your WordPressDeveloping digital marketing into your WordPress
Developing digital marketing into your WordPressAustin Gunter
 
Supporting Wordpress
Supporting WordpressSupporting Wordpress
Supporting Wordpressmasonjames
 
WordPress Security from WordCamp NYC 2012
WordPress Security from WordCamp NYC 2012WordPress Security from WordCamp NYC 2012
WordPress Security from WordCamp NYC 2012Brad Williams
 
WordPress for Nonprofits Using CiviCRM
WordPress for Nonprofits Using CiviCRMWordPress for Nonprofits Using CiviCRM
WordPress for Nonprofits Using CiviCRMTadpole Collective
 

Viewers also liked (7)

Firstborn child theme word camp presentation - atlanta 2013
Firstborn child theme   word camp presentation - atlanta 2013Firstborn child theme   word camp presentation - atlanta 2013
Firstborn child theme word camp presentation - atlanta 2013
 
Google loves WordPress - Blogging For SEO WordCamp NYC 2012
Google loves WordPress - Blogging For SEO WordCamp NYC 2012Google loves WordPress - Blogging For SEO WordCamp NYC 2012
Google loves WordPress - Blogging For SEO WordCamp NYC 2012
 
Killer Docs for Killer Devs
Killer Docs for Killer DevsKiller Docs for Killer Devs
Killer Docs for Killer Devs
 
Developing digital marketing into your WordPress
Developing digital marketing into your WordPressDeveloping digital marketing into your WordPress
Developing digital marketing into your WordPress
 
Supporting Wordpress
Supporting WordpressSupporting Wordpress
Supporting Wordpress
 
WordPress Security from WordCamp NYC 2012
WordPress Security from WordCamp NYC 2012WordPress Security from WordCamp NYC 2012
WordPress Security from WordCamp NYC 2012
 
WordPress for Nonprofits Using CiviCRM
WordPress for Nonprofits Using CiviCRMWordPress for Nonprofits Using CiviCRM
WordPress for Nonprofits Using CiviCRM
 

Similar to Customizing the custom loop wordcamp 2012-jeff

Building a Simple Theme Framework
Building a Simple Theme FrameworkBuilding a Simple Theme Framework
Building a Simple Theme FrameworkJoe Casabona
 
Theming moodle technical
Theming moodle   technicalTheming moodle   technical
Theming moodle technicalAlex Walker
 
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
 
Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016David Brattoli
 
JSLink for ITPros - SharePoint Saturday Jersey
JSLink for ITPros - SharePoint Saturday JerseyJSLink for ITPros - SharePoint Saturday Jersey
JSLink for ITPros - SharePoint Saturday JerseyPaul Hunt
 
A tale of 3 databases
A tale of 3 databasesA tale of 3 databases
A tale of 3 databasesChris Skardon
 
Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008Eric D.
 
WordPress Themes Demystified
WordPress Themes DemystifiedWordPress Themes Demystified
WordPress Themes DemystifiedChris Burgess
 
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
 
PEPY Wordpress workshop-01
PEPY Wordpress workshop-01PEPY Wordpress workshop-01
PEPY Wordpress workshop-01Wei Peng
 
Advanced CSS Troubleshooting
Advanced CSS TroubleshootingAdvanced CSS Troubleshooting
Advanced CSS TroubleshootingDenise Jacobs
 
How to Choose a WordPress Theme
How to Choose a WordPress ThemeHow to Choose a WordPress Theme
How to Choose a WordPress ThemeNew Tricks
 
11 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 201411 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 2014WordPressBrisbane
 
MongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combinationMongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combinationSteven Francia
 
Rapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with BootstrapRapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with BootstrapJosh Jeffryes
 
Untangling spring week2
Untangling spring week2Untangling spring week2
Untangling spring week2Derek Jacoby
 
WebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D EngineWebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D Engineaerotwist
 

Similar to Customizing the custom loop wordcamp 2012-jeff (20)

Building a Simple Theme Framework
Building a Simple Theme FrameworkBuilding a Simple Theme Framework
Building a Simple Theme Framework
 
Theming moodle technical
Theming moodle   technicalTheming moodle   technical
Theming moodle technical
 
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)
 
onGameStart
onGameStartonGameStart
onGameStart
 
Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016
 
JSLink for ITPros - SharePoint Saturday Jersey
JSLink for ITPros - SharePoint Saturday JerseyJSLink for ITPros - SharePoint Saturday Jersey
JSLink for ITPros - SharePoint Saturday Jersey
 
A tale of 3 databases
A tale of 3 databasesA tale of 3 databases
A tale of 3 databases
 
Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008
 
WordPress Themes Demystified
WordPress Themes DemystifiedWordPress Themes Demystified
WordPress Themes Demystified
 
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
 
PEPY Wordpress workshop-01
PEPY Wordpress workshop-01PEPY Wordpress workshop-01
PEPY Wordpress workshop-01
 
Evaluating Base Themes
Evaluating Base ThemesEvaluating Base Themes
Evaluating Base Themes
 
Advanced CSS Troubleshooting
Advanced CSS TroubleshootingAdvanced CSS Troubleshooting
Advanced CSS Troubleshooting
 
How to Choose a WordPress Theme
How to Choose a WordPress ThemeHow to Choose a WordPress Theme
How to Choose a WordPress Theme
 
Design todevelop
Design todevelopDesign todevelop
Design todevelop
 
11 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 201411 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 2014
 
MongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combinationMongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combination
 
Rapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with BootstrapRapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with Bootstrap
 
Untangling spring week2
Untangling spring week2Untangling spring week2
Untangling spring week2
 
WebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D EngineWebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D Engine
 

Recently uploaded

SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Recently uploaded (20)

SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Customizing the custom loop wordcamp 2012-jeff

  • 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 Years WordPress for 7 years •Worked at Bloomberg • Worked at Gannett Businessweek Newspapers •He's the one with the • Not the guy from the beard Sopranos (even though he looks like him)
  • 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  http://codex.wordpress.org/Class_Reference/WP_Query query_posts() and get_posts() actually use this internally, but either do other things that you don't want or won’t give you what you 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
  • 15. Custom Loop Examples  Homepage: https:// github.com/jmarx/Wordcamp-NYC-2012/blob/master/twenty  Sidebar: https:// github.com/jmarx/Wordcamp-NYC-2012/blob/master/twenty  Page https:// github.com/jmarx/Wordcamp-NYC-2012/blob/master/twenty
  • 16. Performance Gotchas • Use caching and transients to improve performance • Limits load by minimizing database calls • Always cache your site when using custom loops! Links: http://wordpress.org/extend/plugins/wp-super-cache/ http://wordpress.org/extend/plugins/w3-total-cache/ http://codex.wordpress.org/Transients_API