WordPress is powered by magic and jazz music. This talk demystifies one of the fundamental components of the WordPress software, WP_Query and the Loop. We’ll talk about URL query strings, how they are used in WordPress and how to manipulate them to control the behavior and output of your site. We’ll also talk about the Loop, what it does, how it works and how to create custom Loops specific to the needs of your project.
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Who's afraid of the big bad loop?
1. Who’s afraid of the
BIG BAD WOLF?
Chris Reynolds@jazzs3quence
LOOP
2. Who’s afraid of the
BIG BAD WOLF?
Chris Reynolds@jazzs3quence
LOOP
3. DA LOOP? WHO DIS?
Who’s afraid of the big bad Loop?
4. DA LOOP? WHO DIS?
Who’s afraid of the big bad Loop?
“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.”
— WordPress Codex
5. DA LOOP? WHO DIS?
Who’s afraid of the big bad Loop?
lolwut
6. DA LOOP? WHO DIS?
Who’s afraid of the big bad Loop?
lolwut
7. DA LOOP? WHO DIS?
Who’s afraid of the big bad Loop?
lolwut
8. DA LOOP? WHO DIS?
Who’s afraid of the big bad Loop?
lolwut
9. DA LOOP? WHO DIS?
Who’s afraid of the big bad Loop?
10. DA LOOP? WHO DIS?
Who’s afraid of the big bad Loop?
11. DA LOOP? WHO DIS?
Who’s afraid of the big bad Loop?
12. DA LOOP? WHO DIS?
Who’s afraid of the big bad Loop?
67. Title of the Proposal
?
reset_postdata
wp_reset_postdata
wp_reset_query
?
68. wp_reset_query
https://www.dropbox.com/s/g3qv4965tb3bhzt/
Screenshot%202018-06-25%2009.21.54.png?dl=0
Who’s afraid of the big bad Loop?
wp_reset_query() restores the $wp_query and global post
data to the original main query. This function should be called
after query_posts(), if you must use that function. As noted in
the examples below, it's heavily encouraged to use the
pre_get_posts filter to alter query parameters before the
query is made.
Calling wp_reset_query is not necessary after using
WP_Query or get_posts as these don't modify the main query
object. Instead use wp_reset_postdata
69. wp_reset_postdata
https://www.dropbox.com/s/g3qv4965tb3bhzt/
Screenshot%202018-06-25%2009.21.54.png?dl=0
Who’s afraid of the big bad Loop?
Use this function to restore the context of the template tags
from a secondary query loop back to the main query loop.
A secondary query loop using $sec_query = new WP_Query()
and $sec_query->the_post() affects the global $post
variable. The global $post variable is used by template tags
by default. wp_reset_postdata() restores the global $post
variable to the current post in the main query (contained in
the global $wp_query variable as opposed to the $sec_query
variable), so that the template tags refer to the main query
loop by default again.
91. query_posts
https://www.dropbox.com/s/g3qv4965tb3bhzt/
Screenshot%202018-06-25%2009.21.54.png?dl=0
Who’s afraid of the big bad Loop?
Note: This function will completely override the
main query and isn’t intended for use by plugins
or themes. Its overly-simplistic approach to
modifying the main query can be problematic
and should be avoided wherever possible. In
most cases, there are better, more performant
options for modifying the main query such as via
the 'pre_get_posts' action within WP_Query.
92. The Loop
How WordPress fetches
posts.
get_posts
Returns the array of posts
from any query (including
the main query).
The Magic
All WordPress queries are
based around URL query
variables that are secretly
hidden.
WP_Query
Runs a WordPress query
for posts.
Resetting Post Data
Always use
wp_reset_postdata after
secondary queries. Period.
query_posts
Don’t use. Ever.
REVIEW!
93. QUESTIONS?
CHRIS REYNOLDS
Senior WordPress Engineer
@ Human Made
@jazzs3quence
https://github.com/jazzsequence
https://chrisreynolds.io
https://jazzsequence.com
http://s3q.us/wcden2018-loop