SlideShare ist ein Scribd-Unternehmen logo
1 von 69
Downloaden Sie, um offline zu lesen
WordCamp Netherlands 2012
Andrew Nacin
Core Developer of WordPress
and Tech Ninja at Audrey Capital

@nacin on Twitter
nacin@wordpress.org
You Don’t Know Query
What do you know?
Conditional Tags


is_author( ), is_home( ), etc.
query_posts( )
Ways to query

query_posts( )
new WP_Query( )
get_posts( )
The Loop


while ( have_posts( ) ) :
  the_post( );
endwhile;
A secondary loop

$query = new WP_Query( 
 );
while ( $query->have_posts( ) ) :
  $query->the_post( );
endwhile;
An array of posts

$result = get_posts( 
 );
foreach ( $result as $post_obj ) {

}
What don’t you know?
Every query object has its
own methods
is_author( ) is the same as calling
$wp_query->is_author( )
function is_author( ) {
  global $wp_query;

    return $wp_query->is_author( );
}
With the regular loop


while ( have_posts( ) ) :
  the_post( );
  if ( is_author( ) )
     echo "An author query.";
endwhile;
With the regular loop


while ( have_posts( ) ) :
  the_post( );
  if ( $wp_query->is_author( ) )
     echo "An author query.";
endwhile;
A secondary loop

$query = new WP_Query( 
 );
while ( $query->have_posts( ) ) :
  $query->the_post( );
  if ( $query->is_author( ) )
     echo "An author query.";
endwhile;
A secondary loop

$query = new WP_Query( 
 );
while ( $query->have_posts( ) ) :
  $query->the_post( );
  if ( $query->is_author( ) )
     echo "An author query.";
endwhile;
A secondary loop

$query = new WP_Query( 
 );
while ( $query->have_posts( ) ) :
  $query->the_post( );
  if ( $query->is_author( ) )
     echo "An author query.";
endwhile;
If you do:
$my_query = new WP_Query( $query );

You can do:
while ( $my_query->have_posts( ) ) :
 $my_query->the_post( );
endwhile;
wp_reset_postdata( );
Why do we call functions like
wp_reset_postdata( ) and
wp_reset_query( )?

What about using query_posts( )?

How can you alter a query? How
can you alter the main query?
What is the main query,
and why should I care?
wp-blog-header.php
// Load the WordPress bootstrap
require './wp-load.php';

// Do magic
wp( );

// Decide which template ïŹles to load
require WPINC . '/template-loader.php';
Let's look in the bootstrap:

$wp_the_query = new WP_Query();
$wp_query =& $wp_the_query;
Quick lesson on PHP references
$a = 4;
$b =& $a;
$b = 2;
var_dump( $a ); // int(2)
$a = 6;
var_dump( $b ); // int(6)
So:
So the real main query is in
$wp_the_query.

And a live copy of it is stored in
$wp_query.
wp-blog-header.php
// Load the WordPress bootstrap
require './wp-load.php';

// Do magic
wp( );

// Decide which template ïŹles to load
require WPINC . '/template-loader.php';
wp-blog-header.php
// Load the WordPress bootstrap
require './wp-load.php';

// Do magic
wp( );

// Decide which template ïŹles to load
require WPINC . '/template-loader.php';
What is that wp( ) call?

function wp( $query_vars = '' ) {
  global $wp;

    $wp->main( $query_vars );
}
Holy $!@?, what just
happened?
In the bootstrap:

$wp = new WP( );

So there's a wp( ) function,
and a WP class.
class WP {
    . . .
    function main( ) {
        $this->init( );
        $this->parse_request( );
        $this->send_headers( );
        $this->query_posts( );
        $this->handle_404( );
        $this->register_globals( );
   . . .
class WP {
    . . .
    function main( ) {
        $this->init( );
        $this->parse_request( );
        $this->send_headers( );
        $this->query_posts( );
        $this->handle_404( );
        $this->register_globals( );
   . . .
WP::parse_request( )
— Parses the URL using WP_Rewrite
— Sets up query variables for WP_Query

WP::query_posts( ) {
  global $wp_the_query;
  $wp_the_query->query( $this->query_vars );
}
Boom.
SELECT SQL_CALC_FOUND_ROWS
  wp_posts.*
FROM wp_posts
WHERE 1=1
  AND wp_posts.post_type = 'post'
  AND wp_posts.post_status = 'publish'
ORDER BY wp_posts.post_date DESC
LIMIT 0, 10
wp-blog-header.php
// Load WordPress.
require './wp-load.php';

// Parse what to query. Then query it.
wp( );

// Load the theme.
require WPINC . '/template-loader.php';
Before we get to the theme,
we have your posts.

Got it?
Then why do we do this?

query_posts( 'author=-5' );
get_header( );
while( have_posts( ) ) :
  the_post( );
endwhile;
get_footer( );
That's running 2* queries!

One, the query WordPress
thought we wanted.

Two, this new one you're
actually going to use.
* Actually, WP_Query
doesn't run just one query.
It usually runs four.
1. Get me my posts:
    SELECT
    SQL_CALC_FOUND_ROWS 

    FROM wp_posts LIMIT 0, 10
2. How many posts exist?
    SELECT FOUND_ROWS( )
3. Get all metadata for these posts.
4. Get all terms for these posts.
(You can turn these oïŹ€ selectively
)

$my_query = new WP_Query( array(
     'no_found_rows' => true,
     'update_post_meta_cache' => false,
     'update_post_term_cache' => false,
) );
</aside>
PROTIP
‘Measure twice, cut once’
is bad for performance.
Other problems with
query_posts( )
Pagination breaks.

WordPress calculated
paging using the query it
did, not the query you did.
query_posts( array(
  'author' => -5,
  'posts_per_page' => 25,
) );

This will not work well.
You easily mess up globals.


This can break widgets and
more.
query_posts( ) is bad.

Do we agree?
Introducing pre_get_posts
class WP_Query {
   . . .
   function &get_posts() {
       $this->parse_query();
       // Huzzah!
       do_action_ref_array( 'pre_get_posts',
          array( &$this ) );
   . . .
A truly awesome hook.

function nacin_alter_home( $query ) {
  if ( $query->is_home( ) )
         $query->set( 'author', '-5' );
}
add_action( 'pre_get_posts', 'nacin_alter_home' );
Still with us?


Good, ‘cause here’s where
things get complicated.
'pre_get_posts' ïŹres for every post
query:
 — get_posts( )
 — new WP_Query( )
 — That random recent posts widget your client
installed without you knowing.
 — Everything.
What if I just want it on the
main query?
$wp_the_query makes a
triumphant return.
Main query only!

function nacin_alter_home( $query ) {
  global $wp_the_query;
  if ( $wp_the_query === $query
             && $query->is_home() )
                  $query->set( 'author', '-5' );
}
add_action( 'pre_get_posts', 'nacin_alter_home' );
Hmm. How does this work?

$wp_the_query should never be modiïŹed. It
holds the main query, forever.

$wp_query keeps a live reference to
$wp_the_query, unless you use
query_posts( ).
query_posts( 'author=-5' );
while ( have_posts( ) ) :
  the_post( );
endwhile;
wp_reset_query( );
query_posts( 'author=-5' );
while ( have_posts( ) ) :
  the_post( );
endwhile;
wp_reset_query( );
function query_posts( $query ) {
  // Break the reference to $wp_the_query
  unset( $wp_query );
  $wp_query =& new WP_Query( $query );
  return $wp_query;
}
query_posts( 'author=-5' );
while ( have_posts( ) ) :
  the_post( );
endwhile;
wp_reset_query( );
function wp_reset_query( ) {
  // Restore reference to $wp_the_query
  unset( $wp_query );
  $wp_query =& $wp_the_query;
  // Reset the globals, too.
  wp_reset_postdata( );
}
Calling the_post( )?
  wp_reset_query( ) will reset $wp_query
  and the globals.

Calling $my_query->the_post( )?
  wp_reset_postdata( ) will reset the globals.
New in WordPress 3.3!
Rather than:
     $wp_the_query === $other_query_object
	
  
You can call:
     $other_query_object->is_main_query( )
	
  
is_main_query( ), the function, will act on
$wp_query, like any other conditional tag.
What about page
templates?
/* Template: My Template */

query_posts( $query_string .
  '&author=-5&posts_per_page=25' );

get_header( );

while ( have_posts( ) ) :
  the_post( );
endwhile;
function nacin_my_template( $query ) {
  if ( ! $query->is_main_query( ) )
      return;
  if ( ! is_page_template( 'my-template.php' ) )
      return;
  $query->set( 'author', '-5' );
  $query->set( 'posts_per_page', '25' );
}
add_action( 'pre_get_posts',
                     'nacin_my_template' );
Some Lessons
Every WP_Query object has methods that
mimic the global conditional tags.

The global conditional tags apply to
$wp_query, the main or current query.

$wp_query is always the main query, unless
you use query_posts( ). Restore it with
wp_reset_query( ).
And Finally
pre_get_posts is a powerful and ïŹ‚exible hook.
Just use it properly.

Always check if you're modifying the main
query using $query->is_main_query( )
Thanks! Questions?


@nacin

Weitere Àhnliche Inhalte

Was ist angesagt?

Trees In The Database - Advanced data structures
Trees In The Database - Advanced data structuresTrees In The Database - Advanced data structures
Trees In The Database - Advanced data structuresLorenzo Alberton
 
Plsql
PlsqlPlsql
Plsqlrchbeir
 
Clean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionClean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionKent Huang
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from insidejulien pauli
 
Jpa 잘 (허는 ᄎᅄᆚ) 허ᄀᅔ
Jpa 잘 (허는 ᄎᅄᆚ) 허ᄀᅔJpa 잘 (허는 ᄎᅄᆚ) 허ᄀᅔ
Jpa 잘 (허는 ᄎᅄᆚ) 허ᄀᅔêČœì› 읎
 
Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)Scott Wlaschin
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for BeginnersVineet Kumar Saini
 
QA Fes 2016. АлДĐșсДĐč Đ’ĐžĐœĐŸĐłŃ€Đ°ĐŽĐŸĐČ. Page Objects: Đ»ŃƒŃ‡ŃˆĐ” ĐżŃ€ĐŸŃ‰Đ”, ĐŽĐ° Đ»ŃƒŃ‡Ńˆe
QA Fes 2016. АлДĐșсДĐč Đ’ĐžĐœĐŸĐłŃ€Đ°ĐŽĐŸĐČ. Page Objects: Đ»ŃƒŃ‡ŃˆĐ” ĐżŃ€ĐŸŃ‰Đ”, ĐŽĐ° Đ»ŃƒŃ‡ŃˆeQA Fes 2016. АлДĐșсДĐč Đ’ĐžĐœĐŸĐłŃ€Đ°ĐŽĐŸĐČ. Page Objects: Đ»ŃƒŃ‡ŃˆĐ” ĐżŃ€ĐŸŃ‰Đ”, ĐŽĐ° Đ»ŃƒŃ‡Ńˆe
QA Fes 2016. АлДĐșсДĐč Đ’ĐžĐœĐŸĐłŃ€Đ°ĐŽĐŸĐČ. Page Objects: Đ»ŃƒŃ‡ŃˆĐ” ĐżŃ€ĐŸŃ‰Đ”, ĐŽĐ° Đ»ŃƒŃ‡ŃˆeQAFest
 
Gestion comptes bancaires Spring boot
Gestion comptes bancaires Spring bootGestion comptes bancaires Spring boot
Gestion comptes bancaires Spring bootAbdelhakim HADI ALAOUI
 
php2 : formulaire-session-PDO
php2 : formulaire-session-PDOphp2 : formulaire-session-PDO
php2 : formulaire-session-PDOAbdoulaye Dieng
 
Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)Scott Wlaschin
 
[COSCUP 2022] èź“é»‘ç•«éąć†æŹĄć‰ć€§ - 甹 PHP 毫 CLI ć·„ć…·
[COSCUP 2022] èź“é»‘ç•«éąć†æŹĄć‰ć€§ - 甹 PHP 毫 CLI ć·„ć…·[COSCUP 2022] èź“é»‘ç•«éąć†æŹĄć‰ć€§ - 甹 PHP 毫 CLI ć·„ć…·
[COSCUP 2022] èź“é»‘ç•«éąć†æŹĄć‰ć€§ - 甹 PHP 毫 CLI ć·„ć…·Shengyou Fan
 
Spring Certification Questions
Spring Certification QuestionsSpring Certification Questions
Spring Certification QuestionsSpringMockExams
 
Optional in Java 8
Optional in Java 8Optional in Java 8
Optional in Java 8Richard Walker
 
Mongodb Aggregation Pipeline
Mongodb Aggregation PipelineMongodb Aggregation Pipeline
Mongodb Aggregation Pipelinezahid-mian
 
Impact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesImpact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesOdoo
 

Was ist angesagt? (20)

Trees In The Database - Advanced data structures
Trees In The Database - Advanced data structuresTrees In The Database - Advanced data structures
Trees In The Database - Advanced data structures
 
Sql Antipatterns Strike Back
Sql Antipatterns Strike BackSql Antipatterns Strike Back
Sql Antipatterns Strike Back
 
Sql Injection Myths and Fallacies
Sql Injection Myths and FallaciesSql Injection Myths and Fallacies
Sql Injection Myths and Fallacies
 
Plsql
PlsqlPlsql
Plsql
 
Clean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionClean Code: Chapter 3 Function
Clean Code: Chapter 3 Function
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from inside
 
Jpa 잘 (허는 ᄎᅄᆚ) 허ᄀᅔ
Jpa 잘 (허는 ᄎᅄᆚ) 허ᄀᅔJpa 잘 (허는 ᄎᅄᆚ) 허ᄀᅔ
Jpa 잘 (허는 ᄎᅄᆚ) 허ᄀᅔ
 
Models for hierarchical data
Models for hierarchical dataModels for hierarchical data
Models for hierarchical data
 
Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
QA Fes 2016. АлДĐșсДĐč Đ’ĐžĐœĐŸĐłŃ€Đ°ĐŽĐŸĐČ. Page Objects: Đ»ŃƒŃ‡ŃˆĐ” ĐżŃ€ĐŸŃ‰Đ”, ĐŽĐ° Đ»ŃƒŃ‡Ńˆe
QA Fes 2016. АлДĐșсДĐč Đ’ĐžĐœĐŸĐłŃ€Đ°ĐŽĐŸĐČ. Page Objects: Đ»ŃƒŃ‡ŃˆĐ” ĐżŃ€ĐŸŃ‰Đ”, ĐŽĐ° Đ»ŃƒŃ‡ŃˆeQA Fes 2016. АлДĐșсДĐč Đ’ĐžĐœĐŸĐłŃ€Đ°ĐŽĐŸĐČ. Page Objects: Đ»ŃƒŃ‡ŃˆĐ” ĐżŃ€ĐŸŃ‰Đ”, ĐŽĐ° Đ»ŃƒŃ‡Ńˆe
QA Fes 2016. АлДĐșсДĐč Đ’ĐžĐœĐŸĐłŃ€Đ°ĐŽĐŸĐČ. Page Objects: Đ»ŃƒŃ‡ŃˆĐ” ĐżŃ€ĐŸŃ‰Đ”, ĐŽĐ° Đ»ŃƒŃ‡Ńˆe
 
Gestion comptes bancaires Spring boot
Gestion comptes bancaires Spring bootGestion comptes bancaires Spring boot
Gestion comptes bancaires Spring boot
 
php2 : formulaire-session-PDO
php2 : formulaire-session-PDOphp2 : formulaire-session-PDO
php2 : formulaire-session-PDO
 
Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)Functional Design Patterns (DevTernity 2018)
Functional Design Patterns (DevTernity 2018)
 
New PHP Exploitation Techniques
New PHP Exploitation TechniquesNew PHP Exploitation Techniques
New PHP Exploitation Techniques
 
[COSCUP 2022] èź“é»‘ç•«éąć†æŹĄć‰ć€§ - 甹 PHP 毫 CLI ć·„ć…·
[COSCUP 2022] èź“é»‘ç•«éąć†æŹĄć‰ć€§ - 甹 PHP 毫 CLI ć·„ć…·[COSCUP 2022] èź“é»‘ç•«éąć†æŹĄć‰ć€§ - 甹 PHP 毫 CLI ć·„ć…·
[COSCUP 2022] èź“é»‘ç•«éąć†æŹĄć‰ć€§ - 甹 PHP 毫 CLI ć·„ć…·
 
Spring Certification Questions
Spring Certification QuestionsSpring Certification Questions
Spring Certification Questions
 
Optional in Java 8
Optional in Java 8Optional in Java 8
Optional in Java 8
 
Mongodb Aggregation Pipeline
Mongodb Aggregation PipelineMongodb Aggregation Pipeline
Mongodb Aggregation Pipeline
 
Impact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesImpact of the New ORM on Your Modules
Impact of the New ORM on Your Modules
 

Andere mochten auch

Advanced Custom Fields ă‹ă‚™é‡ă™ăă‚™ă‚‹ăšæ„Ÿă—ă‚™ă‚‹ă‚ăȘたま
Advanced Custom Fields ă‹ă‚™é‡ă™ăă‚™ă‚‹ăšæ„Ÿă—ă‚™ă‚‹ă‚ăȘたま Advanced Custom Fields ă‹ă‚™é‡ă™ăă‚™ă‚‹ăšæ„Ÿă—ă‚™ă‚‹ă‚ăȘたま
Advanced Custom Fields ă‹ă‚™é‡ă™ăă‚™ă‚‹ăšæ„Ÿă—ă‚™ă‚‹ă‚ăȘたま ă‚żă‚«ă‚· キタゾマ
 
これからぼpre_get_postsăźè©±ă‚’ă—ă‚ˆă†
これからぼpre_get_postsăźè©±ă‚’ă—ă‚ˆă†ă“ă‚Œă‹ă‚‰ăźpre_get_postsăźè©±ă‚’ă—ă‚ˆă†
これからぼpre_get_postsăźè©±ă‚’ă—ă‚ˆă†Hishikawa Takuro
 
WordPressé–ąæ•°ăźć‡Šç†ă‚łă‚čăƒˆă‚’è€ƒăˆă‚ˆă†
WordPressé–ąæ•°ăźć‡Šç†ă‚łă‚čăƒˆă‚’è€ƒăˆă‚ˆă†WordPressé–ąæ•°ăźć‡Šç†ă‚łă‚čăƒˆă‚’è€ƒăˆă‚ˆă†
WordPressé–ąæ•°ăźć‡Šç†ă‚łă‚čăƒˆă‚’è€ƒăˆă‚ˆă†Naoki Matsuda
 
RDSă‚čă‚±ăƒŒăƒ«ă‚ąăƒƒăƒ—ć‰ăźă‚ąăƒ—ăƒȘăƒăƒ„ăƒŒăƒ‹ăƒłă‚°ïŒˆă–ăŁăă‚Šç‰ˆïŒ‰
RDSă‚čă‚±ăƒŒăƒ«ă‚ąăƒƒăƒ—ć‰ăźă‚ąăƒ—ăƒȘăƒăƒ„ăƒŒăƒ‹ăƒłă‚°ïŒˆă–ăŁăă‚Šç‰ˆïŒ‰RDSă‚čă‚±ăƒŒăƒ«ă‚ąăƒƒăƒ—ć‰ăźă‚ąăƒ—ăƒȘăƒăƒ„ăƒŒăƒ‹ăƒłă‚°ïŒˆă–ăŁăă‚Šç‰ˆïŒ‰
RDSă‚čă‚±ăƒŒăƒ«ă‚ąăƒƒăƒ—ć‰ăźă‚ąăƒ—ăƒȘăƒăƒ„ăƒŒăƒ‹ăƒłă‚°ïŒˆă–ăŁăă‚Šç‰ˆïŒ‰Masaru Tomonaga
 
ă‚«ă‚čă‚żăƒ ăƒ•ă‚ŁăƒŒăƒ«ăƒ‰ă‚’ă‚‚ăŁăšäœżă„æ˜“ăïŒ
ă‚«ă‚čă‚żăƒ ăƒ•ă‚ŁăƒŒăƒ«ăƒ‰ă‚’ă‚‚ăŁăšäœżă„æ˜“ăïŒă‚«ă‚čă‚żăƒ ăƒ•ă‚ŁăƒŒăƒ«ăƒ‰ă‚’ă‚‚ăŁăšäœżă„æ˜“ăïŒ
ă‚«ă‚čă‚żăƒ ăƒ•ă‚ŁăƒŒăƒ«ăƒ‰ă‚’ă‚‚ăŁăšäœżă„æ˜“ăïŒé›„äž€éƒŽ 漉怍
 
WordPress ăźă‚­ăƒŁăƒƒă‚·ăƒ„æ©Ÿæ§‹
WordPress ăźă‚­ăƒŁăƒƒă‚·ăƒ„æ©Ÿæ§‹WordPress ăźă‚­ăƒŁăƒƒă‚·ăƒ„æ©Ÿæ§‹
WordPress ăźă‚­ăƒŁăƒƒă‚·ăƒ„æ©Ÿæ§‹katanyan
 
WordCamp Netherlands 2012: WordPress in 2012
WordCamp Netherlands 2012: WordPress in 2012WordCamp Netherlands 2012: WordPress in 2012
WordCamp Netherlands 2012: WordPress in 2012andrewnacin
 
Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...
Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...
Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...andrewnacin
 
Integrating External APIs with WordPress
Integrating External APIs with WordPressIntegrating External APIs with WordPress
Integrating External APIs with WordPressMarty Thornley
 
How to Get ReTweeted
How to Get ReTweetedHow to Get ReTweeted
How to Get ReTweetedDan Zarrella
 
SEOmoz: The Future of Great Links
SEOmoz: The Future of Great LinksSEOmoz: The Future of Great Links
SEOmoz: The Future of Great LinksRand Fishkin
 
Contact Form 7 ă‚ˆăă‚ă‚‹ă‚«ă‚čă‚żăƒžă‚€ă‚ș
Contact Form 7 ă‚ˆăă‚ă‚‹ă‚«ă‚čă‚żăƒžă‚€ă‚șContact Form 7 ă‚ˆăă‚ă‚‹ă‚«ă‚čă‚żăƒžă‚€ă‚ș
Contact Form 7 ă‚ˆăă‚ă‚‹ă‚«ă‚čă‚żăƒžă‚€ă‚șCherry Pie Web
 
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...andrewnacin
 
Past Present & Future of Personas in Search (extended version)
Past Present & Future of Personas in Search (extended version)Past Present & Future of Personas in Search (extended version)
Past Present & Future of Personas in Search (extended version)Michael King
 
Wil Reynolds - link building mistakes 2011
Wil Reynolds - link building mistakes 2011Wil Reynolds - link building mistakes 2011
Wil Reynolds - link building mistakes 2011Wil Reynolds
 
Digital Marketing Case Study - 200% Growth
Digital Marketing Case Study - 200% GrowthDigital Marketing Case Study - 200% Growth
Digital Marketing Case Study - 200% GrowthSEO Andy
 
Mysql Explain Explained
Mysql Explain ExplainedMysql Explain Explained
Mysql Explain ExplainedJeremy Coates
 
The fork in the road - the Application Modernization Roadmap for Notes/Domin...
The fork in the road -  the Application Modernization Roadmap for Notes/Domin...The fork in the road -  the Application Modernization Roadmap for Notes/Domin...
The fork in the road - the Application Modernization Roadmap for Notes/Domin...John Head
 
Technical SEO - An Introduction to Core Aspects of Technical SEO Best-Practise
Technical SEO - An Introduction to Core Aspects of Technical SEO Best-PractiseTechnical SEO - An Introduction to Core Aspects of Technical SEO Best-Practise
Technical SEO - An Introduction to Core Aspects of Technical SEO Best-PractiseErudite
 
Blue Ocean Strategy
Blue Ocean StrategyBlue Ocean Strategy
Blue Ocean Strategyinfotech101
 

Andere mochten auch (20)

Advanced Custom Fields ă‹ă‚™é‡ă™ăă‚™ă‚‹ăšæ„Ÿă—ă‚™ă‚‹ă‚ăȘたま
Advanced Custom Fields ă‹ă‚™é‡ă™ăă‚™ă‚‹ăšæ„Ÿă—ă‚™ă‚‹ă‚ăȘたま Advanced Custom Fields ă‹ă‚™é‡ă™ăă‚™ă‚‹ăšæ„Ÿă—ă‚™ă‚‹ă‚ăȘたま
Advanced Custom Fields ă‹ă‚™é‡ă™ăă‚™ă‚‹ăšæ„Ÿă—ă‚™ă‚‹ă‚ăȘたま
 
これからぼpre_get_postsăźè©±ă‚’ă—ă‚ˆă†
これからぼpre_get_postsăźè©±ă‚’ă—ă‚ˆă†ă“ă‚Œă‹ă‚‰ăźpre_get_postsăźè©±ă‚’ă—ă‚ˆă†
これからぼpre_get_postsăźè©±ă‚’ă—ă‚ˆă†
 
WordPressé–ąæ•°ăźć‡Šç†ă‚łă‚čăƒˆă‚’è€ƒăˆă‚ˆă†
WordPressé–ąæ•°ăźć‡Šç†ă‚łă‚čăƒˆă‚’è€ƒăˆă‚ˆă†WordPressé–ąæ•°ăźć‡Šç†ă‚łă‚čăƒˆă‚’è€ƒăˆă‚ˆă†
WordPressé–ąæ•°ăźć‡Šç†ă‚łă‚čăƒˆă‚’è€ƒăˆă‚ˆă†
 
RDSă‚čă‚±ăƒŒăƒ«ă‚ąăƒƒăƒ—ć‰ăźă‚ąăƒ—ăƒȘăƒăƒ„ăƒŒăƒ‹ăƒłă‚°ïŒˆă–ăŁăă‚Šç‰ˆïŒ‰
RDSă‚čă‚±ăƒŒăƒ«ă‚ąăƒƒăƒ—ć‰ăźă‚ąăƒ—ăƒȘăƒăƒ„ăƒŒăƒ‹ăƒłă‚°ïŒˆă–ăŁăă‚Šç‰ˆïŒ‰RDSă‚čă‚±ăƒŒăƒ«ă‚ąăƒƒăƒ—ć‰ăźă‚ąăƒ—ăƒȘăƒăƒ„ăƒŒăƒ‹ăƒłă‚°ïŒˆă–ăŁăă‚Šç‰ˆïŒ‰
RDSă‚čă‚±ăƒŒăƒ«ă‚ąăƒƒăƒ—ć‰ăźă‚ąăƒ—ăƒȘăƒăƒ„ăƒŒăƒ‹ăƒłă‚°ïŒˆă–ăŁăă‚Šç‰ˆïŒ‰
 
ă‚«ă‚čă‚żăƒ ăƒ•ă‚ŁăƒŒăƒ«ăƒ‰ă‚’ă‚‚ăŁăšäœżă„æ˜“ăïŒ
ă‚«ă‚čă‚żăƒ ăƒ•ă‚ŁăƒŒăƒ«ăƒ‰ă‚’ă‚‚ăŁăšäœżă„æ˜“ăïŒă‚«ă‚čă‚żăƒ ăƒ•ă‚ŁăƒŒăƒ«ăƒ‰ă‚’ă‚‚ăŁăšäœżă„æ˜“ăïŒ
ă‚«ă‚čă‚żăƒ ăƒ•ă‚ŁăƒŒăƒ«ăƒ‰ă‚’ă‚‚ăŁăšäœżă„æ˜“ăïŒ
 
WordPress ăźă‚­ăƒŁăƒƒă‚·ăƒ„æ©Ÿæ§‹
WordPress ăźă‚­ăƒŁăƒƒă‚·ăƒ„æ©Ÿæ§‹WordPress ăźă‚­ăƒŁăƒƒă‚·ăƒ„æ©Ÿæ§‹
WordPress ăźă‚­ăƒŁăƒƒă‚·ăƒ„æ©Ÿæ§‹
 
WordCamp Netherlands 2012: WordPress in 2012
WordCamp Netherlands 2012: WordPress in 2012WordCamp Netherlands 2012: WordPress in 2012
WordCamp Netherlands 2012: WordPress in 2012
 
Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...
Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...
Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...
 
Integrating External APIs with WordPress
Integrating External APIs with WordPressIntegrating External APIs with WordPress
Integrating External APIs with WordPress
 
How to Get ReTweeted
How to Get ReTweetedHow to Get ReTweeted
How to Get ReTweeted
 
SEOmoz: The Future of Great Links
SEOmoz: The Future of Great LinksSEOmoz: The Future of Great Links
SEOmoz: The Future of Great Links
 
Contact Form 7 ă‚ˆăă‚ă‚‹ă‚«ă‚čă‚żăƒžă‚€ă‚ș
Contact Form 7 ă‚ˆăă‚ă‚‹ă‚«ă‚čă‚żăƒžă‚€ă‚șContact Form 7 ă‚ˆăă‚ă‚‹ă‚«ă‚čă‚żăƒžă‚€ă‚ș
Contact Form 7 ă‚ˆăă‚ă‚‹ă‚«ă‚čă‚żăƒžă‚€ă‚ș
 
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
 
Past Present & Future of Personas in Search (extended version)
Past Present & Future of Personas in Search (extended version)Past Present & Future of Personas in Search (extended version)
Past Present & Future of Personas in Search (extended version)
 
Wil Reynolds - link building mistakes 2011
Wil Reynolds - link building mistakes 2011Wil Reynolds - link building mistakes 2011
Wil Reynolds - link building mistakes 2011
 
Digital Marketing Case Study - 200% Growth
Digital Marketing Case Study - 200% GrowthDigital Marketing Case Study - 200% Growth
Digital Marketing Case Study - 200% Growth
 
Mysql Explain Explained
Mysql Explain ExplainedMysql Explain Explained
Mysql Explain Explained
 
The fork in the road - the Application Modernization Roadmap for Notes/Domin...
The fork in the road -  the Application Modernization Roadmap for Notes/Domin...The fork in the road -  the Application Modernization Roadmap for Notes/Domin...
The fork in the road - the Application Modernization Roadmap for Notes/Domin...
 
Technical SEO - An Introduction to Core Aspects of Technical SEO Best-Practise
Technical SEO - An Introduction to Core Aspects of Technical SEO Best-PractiseTechnical SEO - An Introduction to Core Aspects of Technical SEO Best-Practise
Technical SEO - An Introduction to Core Aspects of Technical SEO Best-Practise
 
Blue Ocean Strategy
Blue Ocean StrategyBlue Ocean Strategy
Blue Ocean Strategy
 

Ähnlich wie You Don't Know Query (WordCamp Netherlands 2012)

You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012l3rady
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011andrewnacin
 
WordPress London 16 May 2012 - You don’t know query
WordPress London 16 May 2012 - You don’t know queryWordPress London 16 May 2012 - You don’t know query
WordPress London 16 May 2012 - You don’t know queryl3rady
 
The Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the QueryThe Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the QueryChris Olbekson
 
WordPress Queries - the right way
WordPress Queries - the right wayWordPress Queries - the right way
WordPress Queries - the right wayAnthony Hortin
 
Getting Creative with WordPress Queries, Again
Getting Creative with WordPress Queries, AgainGetting Creative with WordPress Queries, Again
Getting Creative with WordPress Queries, AgainDrewAPicture
 
Getting to The Loop - London Wordpress Meetup July 28th
Getting to The Loop - London Wordpress Meetup  July 28thGetting to The Loop - London Wordpress Meetup  July 28th
Getting to The Loop - London Wordpress Meetup July 28thChris Adams
 
Getting Creative with WordPress Queries
Getting Creative with WordPress QueriesGetting Creative with WordPress Queries
Getting Creative with WordPress QueriesDrewAPicture
 
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress?
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress?КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress?
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress?Yevhen Kotelnytskyi
 
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress? v2.0
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress? v2.0КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress? v2.0
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress? v2.0Yevhen Kotelnytskyi
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018Adam Tomat
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework appsMichelangelo van Dam
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxMichelangelo van Dam
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11Michelangelo van Dam
 
WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress
WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress
WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress WordCamp Kyiv
 
WordPress as an application framework
WordPress as an application frameworkWordPress as an application framework
WordPress as an application frameworkDustin Filippini
 
WP_Query, pre_get_posts, and eliminating query_posts()
WP_Query, pre_get_posts, and eliminating query_posts()WP_Query, pre_get_posts, and eliminating query_posts()
WP_Query, pre_get_posts, and eliminating query_posts()Erick Hitter
 
Why is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosWhy is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosDivante
 
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014Cliff Seal
 

Ähnlich wie You Don't Know Query (WordCamp Netherlands 2012) (20)

You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012You don’t know query - WordCamp UK Edinburgh 2012
You don’t know query - WordCamp UK Edinburgh 2012
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011
 
WordPress London 16 May 2012 - You don’t know query
WordPress London 16 May 2012 - You don’t know queryWordPress London 16 May 2012 - You don’t know query
WordPress London 16 May 2012 - You don’t know query
 
Wp query
Wp queryWp query
Wp query
 
The Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the QueryThe Query the Whole Query and Nothing but the Query
The Query the Whole Query and Nothing but the Query
 
WordPress Queries - the right way
WordPress Queries - the right wayWordPress Queries - the right way
WordPress Queries - the right way
 
Getting Creative with WordPress Queries, Again
Getting Creative with WordPress Queries, AgainGetting Creative with WordPress Queries, Again
Getting Creative with WordPress Queries, Again
 
Getting to The Loop - London Wordpress Meetup July 28th
Getting to The Loop - London Wordpress Meetup  July 28thGetting to The Loop - London Wordpress Meetup  July 28th
Getting to The Loop - London Wordpress Meetup July 28th
 
Getting Creative with WordPress Queries
Getting Creative with WordPress QueriesGetting Creative with WordPress Queries
Getting Creative with WordPress Queries
 
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress?
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress?КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress?
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress?
 
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress? v2.0
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress? v2.0КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress? v2.0
КаĐș ĐżĐŸĐ»ŃƒŃ‡ĐžŃ‚ŃŒ Ń‡Ń‘Ń€ĐœŃ‹Đč ĐżĐŸŃŃ ĐżĐŸ WordPress? v2.0
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework apps
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
 
WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress
WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress
WordPress Kitchen 2014 - АлДĐșŃĐ°ĐœĐŽŃ€ Строха: ĐšĐ”ŃˆĐžŃ€ĐŸĐČĐ°ĐœĐžĐ” ĐČ WordPress
 
WordPress as an application framework
WordPress as an application frameworkWordPress as an application framework
WordPress as an application framework
 
WP_Query, pre_get_posts, and eliminating query_posts()
WP_Query, pre_get_posts, and eliminating query_posts()WP_Query, pre_get_posts, and eliminating query_posts()
WP_Query, pre_get_posts, and eliminating query_posts()
 
Why is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosWhy is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenarios
 
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
Temporary Cache Assistance (Transients API): WordCamp Phoenix 2014
 

Mehr von andrewnacin

WordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPressWordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPressandrewnacin
 
Open Source (and you can too) - 2011 Teens in Tech Conference
Open Source (and you can too) - 2011 Teens in Tech ConferenceOpen Source (and you can too) - 2011 Teens in Tech Conference
Open Source (and you can too) - 2011 Teens in Tech Conferenceandrewnacin
 
WordCamp Columbus 2011 - What's Next for WordPress
WordCamp Columbus 2011 - What's Next for WordPressWordCamp Columbus 2011 - What's Next for WordPress
WordCamp Columbus 2011 - What's Next for WordPressandrewnacin
 
TEDxYouth@DowntownDC
TEDxYouth@DowntownDCTEDxYouth@DowntownDC
TEDxYouth@DowntownDCandrewnacin
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)andrewnacin
 
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)andrewnacin
 
Hidden Features (WordPress DC)
Hidden Features (WordPress DC)Hidden Features (WordPress DC)
Hidden Features (WordPress DC)andrewnacin
 
Lightning Talk: Mistakes (WordCamp Phoenix 2011)
Lightning Talk: Mistakes (WordCamp Phoenix 2011)Lightning Talk: Mistakes (WordCamp Phoenix 2011)
Lightning Talk: Mistakes (WordCamp Phoenix 2011)andrewnacin
 
WordPress at Web Content Mavens (Jan. 2011)
WordPress at Web Content Mavens (Jan. 2011)WordPress at Web Content Mavens (Jan. 2011)
WordPress at Web Content Mavens (Jan. 2011)andrewnacin
 
WordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPWordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPandrewnacin
 
What's Next for WordPress at WordCamp Netherlands
What's Next for WordPress at WordCamp NetherlandsWhat's Next for WordPress at WordCamp Netherlands
What's Next for WordPress at WordCamp Netherlandsandrewnacin
 
What's Next for WordPress: WordCamp Birmingham 2010
What's Next for WordPress: WordCamp Birmingham 2010What's Next for WordPress: WordCamp Birmingham 2010
What's Next for WordPress: WordCamp Birmingham 2010andrewnacin
 
WordPress 3.0 at DC PHP
WordPress 3.0 at DC PHPWordPress 3.0 at DC PHP
WordPress 3.0 at DC PHPandrewnacin
 
Advanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIsAdvanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIsandrewnacin
 

Mehr von andrewnacin (14)

WordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPressWordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPress
 
Open Source (and you can too) - 2011 Teens in Tech Conference
Open Source (and you can too) - 2011 Teens in Tech ConferenceOpen Source (and you can too) - 2011 Teens in Tech Conference
Open Source (and you can too) - 2011 Teens in Tech Conference
 
WordCamp Columbus 2011 - What's Next for WordPress
WordCamp Columbus 2011 - What's Next for WordPressWordCamp Columbus 2011 - What's Next for WordPress
WordCamp Columbus 2011 - What's Next for WordPress
 
TEDxYouth@DowntownDC
TEDxYouth@DowntownDCTEDxYouth@DowntownDC
TEDxYouth@DowntownDC
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)
 
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)
 
Hidden Features (WordPress DC)
Hidden Features (WordPress DC)Hidden Features (WordPress DC)
Hidden Features (WordPress DC)
 
Lightning Talk: Mistakes (WordCamp Phoenix 2011)
Lightning Talk: Mistakes (WordCamp Phoenix 2011)Lightning Talk: Mistakes (WordCamp Phoenix 2011)
Lightning Talk: Mistakes (WordCamp Phoenix 2011)
 
WordPress at Web Content Mavens (Jan. 2011)
WordPress at Web Content Mavens (Jan. 2011)WordPress at Web Content Mavens (Jan. 2011)
WordPress at Web Content Mavens (Jan. 2011)
 
WordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPWordPress 3.1 at DC PHP
WordPress 3.1 at DC PHP
 
What's Next for WordPress at WordCamp Netherlands
What's Next for WordPress at WordCamp NetherlandsWhat's Next for WordPress at WordCamp Netherlands
What's Next for WordPress at WordCamp Netherlands
 
What's Next for WordPress: WordCamp Birmingham 2010
What's Next for WordPress: WordCamp Birmingham 2010What's Next for WordPress: WordCamp Birmingham 2010
What's Next for WordPress: WordCamp Birmingham 2010
 
WordPress 3.0 at DC PHP
WordPress 3.0 at DC PHPWordPress 3.0 at DC PHP
WordPress 3.0 at DC PHP
 
Advanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIsAdvanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIs
 

KĂŒrzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĂșjo
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

KĂŒrzlich hochgeladen (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

You Don't Know Query (WordCamp Netherlands 2012)

  • 2. Andrew Nacin Core Developer of WordPress and Tech Ninja at Audrey Capital @nacin on Twitter nacin@wordpress.org
  • 4. What do you know?
  • 7. Ways to query query_posts( ) new WP_Query( ) get_posts( )
  • 8. The Loop while ( have_posts( ) ) : the_post( ); endwhile;
  • 9. A secondary loop $query = new WP_Query( 
 ); while ( $query->have_posts( ) ) : $query->the_post( ); endwhile;
  • 10. An array of posts $result = get_posts( 
 ); foreach ( $result as $post_obj ) { }
  • 12. Every query object has its own methods is_author( ) is the same as calling $wp_query->is_author( )
  • 13. function is_author( ) { global $wp_query; return $wp_query->is_author( ); }
  • 14. With the regular loop while ( have_posts( ) ) : the_post( ); if ( is_author( ) ) echo "An author query."; endwhile;
  • 15. With the regular loop while ( have_posts( ) ) : the_post( ); if ( $wp_query->is_author( ) ) echo "An author query."; endwhile;
  • 16. A secondary loop $query = new WP_Query( 
 ); while ( $query->have_posts( ) ) : $query->the_post( ); if ( $query->is_author( ) ) echo "An author query."; endwhile;
  • 17. A secondary loop $query = new WP_Query( 
 ); while ( $query->have_posts( ) ) : $query->the_post( ); if ( $query->is_author( ) ) echo "An author query."; endwhile;
  • 18. A secondary loop $query = new WP_Query( 
 ); while ( $query->have_posts( ) ) : $query->the_post( ); if ( $query->is_author( ) ) echo "An author query."; endwhile;
  • 19. If you do: $my_query = new WP_Query( $query ); You can do: while ( $my_query->have_posts( ) ) : $my_query->the_post( ); endwhile; wp_reset_postdata( );
  • 20. Why do we call functions like wp_reset_postdata( ) and wp_reset_query( )? What about using query_posts( )? How can you alter a query? How can you alter the main query?
  • 21. What is the main query, and why should I care?
  • 22. wp-blog-header.php // Load the WordPress bootstrap require './wp-load.php'; // Do magic wp( ); // Decide which template ïŹles to load require WPINC . '/template-loader.php';
  • 23. Let's look in the bootstrap: $wp_the_query = new WP_Query(); $wp_query =& $wp_the_query;
  • 24. Quick lesson on PHP references $a = 4; $b =& $a; $b = 2; var_dump( $a ); // int(2) $a = 6; var_dump( $b ); // int(6)
  • 25. So: So the real main query is in $wp_the_query. And a live copy of it is stored in $wp_query.
  • 26. wp-blog-header.php // Load the WordPress bootstrap require './wp-load.php'; // Do magic wp( ); // Decide which template ïŹles to load require WPINC . '/template-loader.php';
  • 27. wp-blog-header.php // Load the WordPress bootstrap require './wp-load.php'; // Do magic wp( ); // Decide which template ïŹles to load require WPINC . '/template-loader.php';
  • 28. What is that wp( ) call? function wp( $query_vars = '' ) { global $wp; $wp->main( $query_vars ); }
  • 29. Holy $!@?, what just happened?
  • 30. In the bootstrap: $wp = new WP( ); So there's a wp( ) function, and a WP class.
  • 31. class WP { . . . function main( ) { $this->init( ); $this->parse_request( ); $this->send_headers( ); $this->query_posts( ); $this->handle_404( ); $this->register_globals( ); . . .
  • 32. class WP { . . . function main( ) { $this->init( ); $this->parse_request( ); $this->send_headers( ); $this->query_posts( ); $this->handle_404( ); $this->register_globals( ); . . .
  • 33. WP::parse_request( ) — Parses the URL using WP_Rewrite — Sets up query variables for WP_Query WP::query_posts( ) { global $wp_the_query; $wp_the_query->query( $this->query_vars ); }
  • 34. Boom. SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND wp_posts.post_status = 'publish' ORDER BY wp_posts.post_date DESC LIMIT 0, 10
  • 35. wp-blog-header.php // Load WordPress. require './wp-load.php'; // Parse what to query. Then query it. wp( ); // Load the theme. require WPINC . '/template-loader.php';
  • 36. Before we get to the theme, we have your posts. Got it?
  • 37. Then why do we do this? query_posts( 'author=-5' ); get_header( ); while( have_posts( ) ) : the_post( ); endwhile; get_footer( );
  • 38. That's running 2* queries! One, the query WordPress thought we wanted. Two, this new one you're actually going to use.
  • 39. * Actually, WP_Query doesn't run just one query. It usually runs four.
  • 40. 1. Get me my posts: SELECT SQL_CALC_FOUND_ROWS 
 FROM wp_posts LIMIT 0, 10 2. How many posts exist? SELECT FOUND_ROWS( ) 3. Get all metadata for these posts. 4. Get all terms for these posts.
  • 41. (You can turn these oïŹ€ selectively
) $my_query = new WP_Query( array( 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, ) );
  • 43. PROTIP ‘Measure twice, cut once’ is bad for performance.
  • 45. Pagination breaks. WordPress calculated paging using the query it did, not the query you did.
  • 46. query_posts( array( 'author' => -5, 'posts_per_page' => 25, ) ); This will not work well.
  • 47. You easily mess up globals. This can break widgets and more.
  • 48. query_posts( ) is bad. Do we agree?
  • 49. Introducing pre_get_posts class WP_Query { . . . function &get_posts() { $this->parse_query(); // Huzzah! do_action_ref_array( 'pre_get_posts', array( &$this ) ); . . .
  • 50. A truly awesome hook. function nacin_alter_home( $query ) { if ( $query->is_home( ) ) $query->set( 'author', '-5' ); } add_action( 'pre_get_posts', 'nacin_alter_home' );
  • 51. Still with us? Good, ‘cause here’s where things get complicated.
  • 52. 'pre_get_posts' ïŹres for every post query: — get_posts( ) — new WP_Query( ) — That random recent posts widget your client installed without you knowing. — Everything.
  • 53. What if I just want it on the main query?
  • 55. Main query only! function nacin_alter_home( $query ) { global $wp_the_query; if ( $wp_the_query === $query && $query->is_home() ) $query->set( 'author', '-5' ); } add_action( 'pre_get_posts', 'nacin_alter_home' );
  • 56. Hmm. How does this work? $wp_the_query should never be modiïŹed. It holds the main query, forever. $wp_query keeps a live reference to $wp_the_query, unless you use query_posts( ).
  • 57. query_posts( 'author=-5' ); while ( have_posts( ) ) : the_post( ); endwhile; wp_reset_query( );
  • 58. query_posts( 'author=-5' ); while ( have_posts( ) ) : the_post( ); endwhile; wp_reset_query( );
  • 59. function query_posts( $query ) { // Break the reference to $wp_the_query unset( $wp_query ); $wp_query =& new WP_Query( $query ); return $wp_query; }
  • 60. query_posts( 'author=-5' ); while ( have_posts( ) ) : the_post( ); endwhile; wp_reset_query( );
  • 61. function wp_reset_query( ) { // Restore reference to $wp_the_query unset( $wp_query ); $wp_query =& $wp_the_query; // Reset the globals, too. wp_reset_postdata( ); }
  • 62. Calling the_post( )? wp_reset_query( ) will reset $wp_query and the globals. Calling $my_query->the_post( )? wp_reset_postdata( ) will reset the globals.
  • 63. New in WordPress 3.3! Rather than: $wp_the_query === $other_query_object   You can call: $other_query_object->is_main_query( )   is_main_query( ), the function, will act on $wp_query, like any other conditional tag.
  • 65. /* Template: My Template */ query_posts( $query_string . '&author=-5&posts_per_page=25' ); get_header( ); while ( have_posts( ) ) : the_post( ); endwhile;
  • 66. function nacin_my_template( $query ) { if ( ! $query->is_main_query( ) ) return; if ( ! is_page_template( 'my-template.php' ) ) return; $query->set( 'author', '-5' ); $query->set( 'posts_per_page', '25' ); } add_action( 'pre_get_posts', 'nacin_my_template' );
  • 67. Some Lessons Every WP_Query object has methods that mimic the global conditional tags. The global conditional tags apply to $wp_query, the main or current query. $wp_query is always the main query, unless you use query_posts( ). Restore it with wp_reset_query( ).
  • 68. And Finally pre_get_posts is a powerful and ïŹ‚exible hook. Just use it properly. Always check if you're modifying the main query using $query->is_main_query( )