Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active December 29, 2015 05:48
Show Gist options
  • Save hissy/7624074 to your computer and use it in GitHub Desktop.
Save hissy/7624074 to your computer and use it in GitHub Desktop.
is_main_queryを理解する
<?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
@hissy
Copy link
Author

hissy commented Nov 24, 2013

In reply to the question: WordPressでの記事表示とかメインクエリーとかもう一度かんがえてみた http://webourgeon.com/2013/11/24/main-query/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment