Last active
December 29, 2015 05:48
-
-
Save hissy/7624074 to your computer and use it in GitHub Desktop.
is_main_queryを理解する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = new WP_Query; // WP_Queryのインスタンスを作成 | |
$b = $a; // 参照 | |
$c = clone $a; // 複製 | |
$d = new WP_Query; // 別のWP_Queryのインスタンスを作成 | |
var_dump( $a == $b ); // true | |
var_dump( $a === $b ); // true | |
var_dump( $a == $c ); // true | |
var_dump( $a === $c ); // false | |
var_dump( $a == $d ); // true | |
var_dump( $a === $d ); // false | |
global $wp_the_query; | |
$e = $wp_the_query = new WP_Query; | |
$f = clone $wp_the_query; | |
$g = new WP_Query; | |
var_dump( $e->is_main_query() ); // true | |
var_dump( $f->is_main_query() ); // false | |
var_dump( $g->is_main_query() ); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In reply to the question: WordPressでの記事表示とかメインクエリーとかもう一度かんがえてみた http://webourgeon.com/2013/11/24/main-query/