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

Thing to love in Clojure
Thing to love in ClojureThing to love in Clojure
Thing to love in ClojureJiří Knesl
 
WordPress Media in a post-Koop Universe
WordPress Media in a post-Koop UniverseWordPress Media in a post-Koop Universe
WordPress Media in a post-Koop UniverseScott Taylor
 
This is presentation at Mitaka.rb #10.
This is presentation at Mitaka.rb #10.This is presentation at Mitaka.rb #10.
This is presentation at Mitaka.rb #10.Masaki Komagata
 
Startup Weekend & LocomotiveCMS (In Chinese)
Startup Weekend & LocomotiveCMS (In Chinese)Startup Weekend & LocomotiveCMS (In Chinese)
Startup Weekend & LocomotiveCMS (In Chinese)Zac Zheng
 
LeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than developmentLeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than developmentJohn McCaffrey
 
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
 
Custom Post Types in the wild (WordCamp Sofia 2012)
Custom Post Types in the wild (WordCamp Sofia 2012)Custom Post Types in the wild (WordCamp Sofia 2012)
Custom Post Types in the wild (WordCamp Sofia 2012)Mario Peshev
 
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...Carlos Ospina
 
NoTube User Model slides
NoTube User Model slidesNoTube User Model slides
NoTube User Model slidesDan Brickley
 
How to create a podcast
How to create a podcastHow to create a podcast
How to create a podcastChip Dizárd
 
Carrington Core (2014)
Carrington Core (2014)Carrington Core (2014)
Carrington Core (2014)alexkingorg
 
WebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D EngineWebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D Engineaerotwist
 
Custom post types - WordPress
Custom post types - WordPressCustom post types - WordPress
Custom post types - WordPresskeithdevon
 
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
 
Advanced Custom Fields Lightning Talk WordCamp Miami 2018
Advanced Custom Fields Lightning Talk WordCamp Miami 2018Advanced Custom Fields Lightning Talk WordCamp Miami 2018
Advanced Custom Fields Lightning Talk WordCamp Miami 2018Jesse Velez
 

What's hot (20)

Thing to love in Clojure
Thing to love in ClojureThing to love in Clojure
Thing to love in Clojure
 
WordPress Media in a post-Koop Universe
WordPress Media in a post-Koop UniverseWordPress Media in a post-Koop Universe
WordPress Media in a post-Koop Universe
 
Down and Dirty EPUB 3
Down and Dirty EPUB 3Down and Dirty EPUB 3
Down and Dirty EPUB 3
 
This is presentation at Mitaka.rb #10.
This is presentation at Mitaka.rb #10.This is presentation at Mitaka.rb #10.
This is presentation at Mitaka.rb #10.
 
Startup Weekend & LocomotiveCMS (In Chinese)
Startup Weekend & LocomotiveCMS (In Chinese)Startup Weekend & LocomotiveCMS (In Chinese)
Startup Weekend & LocomotiveCMS (In Chinese)
 
LeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than developmentLeanStartup:Research is cheaper than development
LeanStartup:Research is cheaper than development
 
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)
 
Custom Post Types in the wild (WordCamp Sofia 2012)
Custom Post Types in the wild (WordCamp Sofia 2012)Custom Post Types in the wild (WordCamp Sofia 2012)
Custom Post Types in the wild (WordCamp Sofia 2012)
 
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...
Convert a Site Template to a Drupal 7 Theme using SASS or LESS and Zurb Found...
 
Design todevelop
Design todevelopDesign todevelop
Design todevelop
 
Ansible for Automation
Ansible for AutomationAnsible for Automation
Ansible for Automation
 
NoTube User Model slides
NoTube User Model slidesNoTube User Model slides
NoTube User Model slides
 
Blogging
BloggingBlogging
Blogging
 
How to create a podcast
How to create a podcastHow to create a podcast
How to create a podcast
 
Carrington Core (2014)
Carrington Core (2014)Carrington Core (2014)
Carrington Core (2014)
 
WebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D EngineWebGL Camp 4 - A3 3D Engine
WebGL Camp 4 - A3 3D Engine
 
Intro to EmberJS
Intro to EmberJSIntro to EmberJS
Intro to EmberJS
 
Custom post types - WordPress
Custom post types - WordPressCustom post types - WordPress
Custom post types - WordPress
 
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!
 
Advanced Custom Fields Lightning Talk WordCamp Miami 2018
Advanced Custom Fields Lightning Talk WordCamp Miami 2018Advanced Custom Fields Lightning Talk WordCamp Miami 2018
Advanced Custom Fields Lightning Talk WordCamp Miami 2018
 

Similar to Customizing the custom loop wordcamp 2012-jeff

Customizing the custom loop wordcamp 2012
Customizing the custom loop   wordcamp 2012Customizing the custom loop   wordcamp 2012
Customizing the custom loop wordcamp 2012Alexander Sapountzis
 
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
 
WordPress Themes Demystified
WordPress Themes DemystifiedWordPress Themes Demystified
WordPress Themes DemystifiedChris Burgess
 
Open Standards in the Walled Garden
Open Standards in the Walled GardenOpen Standards in the Walled Garden
Open Standards in the Walled Gardendigitalbindery
 
How to Choose a WordPress Theme
How to Choose a WordPress ThemeHow to Choose a WordPress Theme
How to Choose a WordPress ThemeNew Tricks
 
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
 
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
 
Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008Eric D.
 
PEPY Wordpress workshop-01
PEPY Wordpress workshop-01PEPY Wordpress workshop-01
PEPY Wordpress workshop-01Wei Peng
 
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2Curtiss Grymala
 
MongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combinationMongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combinationSteven Francia
 
Gettingintotheloop 100123225021-phpapp01
Gettingintotheloop 100123225021-phpapp01Gettingintotheloop 100123225021-phpapp01
Gettingintotheloop 100123225021-phpapp01Ravi Kumar
 
Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06jimbojsb
 
Theming moodle technical
Theming moodle   technicalTheming moodle   technical
Theming moodle technicalAlex Walker
 
Child Theme Frameworks
Child Theme FrameworksChild Theme Frameworks
Child Theme Frameworksryngrn
 
Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016David Brattoli
 

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

Customizing the custom loop wordcamp 2012
Customizing the custom loop   wordcamp 2012Customizing the custom loop   wordcamp 2012
Customizing the custom loop wordcamp 2012
 
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
 
onGameStart
onGameStartonGameStart
onGameStart
 
WordPress Themes Demystified
WordPress Themes DemystifiedWordPress Themes Demystified
WordPress Themes Demystified
 
Open Standards in the Walled Garden
Open Standards in the Walled GardenOpen Standards in the Walled Garden
Open Standards in the Walled Garden
 
How to Choose a WordPress Theme
How to Choose a WordPress ThemeHow to Choose a WordPress Theme
How to Choose a WordPress Theme
 
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)
 
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
 
Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008Yahoo! Search monkey API - CEBIT 2008
Yahoo! Search monkey API - CEBIT 2008
 
PEPY Wordpress workshop-01
PEPY Wordpress workshop-01PEPY Wordpress workshop-01
PEPY Wordpress workshop-01
 
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
 
MongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combinationMongoDB and Ecommerce : A perfect combination
MongoDB and Ecommerce : A perfect combination
 
Gettingintotheloop 100123225021-phpapp01
Gettingintotheloop 100123225021-phpapp01Gettingintotheloop 100123225021-phpapp01
Gettingintotheloop 100123225021-phpapp01
 
Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06Austin NoSQL 2011-07-06
Austin NoSQL 2011-07-06
 
Theming moodle technical
Theming moodle   technicalTheming moodle   technical
Theming moodle technical
 
Working with WordPress themes
Working with WordPress themesWorking with WordPress themes
Working with WordPress themes
 
OOP in JS
OOP in JSOOP in JS
OOP in JS
 
Child Theme Frameworks
Child Theme FrameworksChild Theme Frameworks
Child Theme Frameworks
 
Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016
 

Recently uploaded

SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
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
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
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
 
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
 

Recently uploaded (20)

SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
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
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
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
 
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
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
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
 

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