Presentation is loading. Please wait.

Presentation is loading. Please wait.

Deconstructing the Loop AL DAVIS WPTEACH.COM

Similar presentations


Presentation on theme: "Deconstructing the Loop AL DAVIS WPTEACH.COM"— Presentation transcript:

1 Deconstructing the Loop AL DAVIS WPTEACH.COM AL@WPTEACH.COM

2 ABOUTME Organizer of: WordCamp Toronto ( 2011, 2012) WordCamp Developers Toronto ( 2012) Toronto WordPress Meetup group Toronto Wordpress Developers Meetup Who is that bald guy at the front of the room? And why is he there? AL DAVIS WPTEACH.COM AL@WPTEACH.COM Program Manager, Hostopia WordPress SME for worlds largest wholesale hosting provider Developing WP strategy for major telcos, cablecos and ISPs globally About to launch a service where we design and publish 1000+ sites a month using WP Professor, George Brown College Intro to WordPress Intro to WordPress theme Development Owner, WPTeach.com WordPress website Launching online school to learn WP in Q2 Freelance WordPress Development

3 LETS GET TO IT THEN AL DAVIS WPTEACH.COM AL@WPTEACH.COM From the codex: "The Loop is PHP code used by WordPress to display posts. Using The Loop, WordPress processes each post to be displayed on the current page, and formats it according to how it matches specified criteria within The Loop tags. Any HTML or PHP code in the Loop will be processed on each post."HTMLPHP What is the Loop? My definition: The Loop is a living, breathing thing. it's the engine that makes WordPress as powerful as it is, it makes everything tick. Without the loop, there is no dynamic content. Using the loop. we can display any content we want, however we want.

4 DECONSTRUCTINGTHELOOP AL DAVIS WPTEACH.COM AL@WPTEACH.COM What does it look like? The Loop I mean….

5 DECONSTRUCTINGTHELOOP Topic AL DAVIS WPTEACH.COM AL@WPTEACH.COM Thanks for your time….. Just kidding…..

6 DECONSTRUCTINGTHELOOP AL DAVIS WPTEACH.COM AL@WPTEACH.COM IN THE BEGINNING… Part 1 - opens and closes the PHP command Part 2 have_posts() - checks to see there are posts to display Part3 the_post- unpacks the next post in the queue. In Plain English Using PHP, check to see if there are any posts to display, if there are, then display them. Stop using PHP.

7 DECONSTRUCTINGTHELOOP AL DAVIS WPTEACH.COM AL@WPTEACH.COM THE ENDING… Part 1 STOP the Loop....but notice the "else" thats in there..... The very first "if" if (have_posts()) tested to see if there were any Posts to display. This "else" part tells what do if there weren't any

8 DECONSTRUCTINGTHELOOP AL DAVIS WPTEACH.COM AL@WPTEACH.COM THE ENDING… Part 2 Nothing to look at here...move along

9 DECONSTRUCTINGTHELOOP AL DAVIS WPTEACH.COM AL@WPTEACH.COM THE ENDING… Part 3 Seriously, stop the loop....now.

10 DECONSTRUCTINGTHELOOP AL DAVIS WPTEACH.COM AL@WPTEACH.COM //Magic happens here ALL TOGETHER NOW….. In Plain English Using PHP, check to see if there are any posts to display, if there are, then display them. If you have reached the number of posts I told you to get, then stop. If you dont find any post based on what I asked for, display the message I told you to. Now seriously, stop…no more.

11 DECONSTRUCTINGTHELOOP AL DAVIS WPTEACH.COM AL@WPTEACH.COM So how does it look? Blank, there is nothing there…. But the good news is, if you have a blank screen you have done nothing wrong.. So how do we make it work like we think it should?

12 DECONSTRUCTINGTHELOOP AL DAVIS WPTEACH.COM AL@WPTEACH.COM Say hello to your new BFF The Template Tag What is a Template Tag? A PHP function used in your WordPress theme template to display specific pieces of data about your web site and your content. This allows you to customize how and where your content is displayed on your website. Example the_title() displays the title of your post or page inside the Loop

13 DECONSTRUCTINGTHELOOP AL DAVIS WPTEACH.COM AL@WPTEACH.COM Why Use Template Tag? Saves you from learning PHP, which makes it worth the price of admission right there

14 DECONSTRUCTINGTHELOOP AL DAVIS WPTEACH.COM AL@WPTEACH.COM Commonly used Template Tags - returns the URL of your post - returns the title of your post or page -returns the unique ID of your post -just the excerpt of the post displays the date/time the post was published - displays the author of the post - displays the categories assigned to the post - Displays the tags assigned to the post Link for the comments on the post

15 DECONSTRUCTINGTHELOOP AL DAVIS WPTEACH.COM AL@WPTEACH.COM Lets see what it looks like in action, shall we?

16 AL DAVIS WPTEACH.COM AL@WPTEACH.COM ? Questions

17 AL DAVIS WPTEACH.COM AL@WPTEACH.COM Thank You Slides are up at wpteach.com


Download ppt "Deconstructing the Loop AL DAVIS WPTEACH.COM"

Similar presentations


Ads by Google