2011-07-30 34 views
0

這裏就是我看到的時候我做的var_dump上一個新WP_Query創建:無法訪問的事情WP_Query對象的內部

object(WP_Query)#115 (45) { 
    ["query_vars"]=> 
    array(55) { 
    ["post_type"]=> 
    string(6) "charity" 
    ["order"]=> 
    string(3) "ASC" 
    ["error"]=> 
    string(0) "" 
    ["m"]=> 
    int(0) 
    ["p"]=> 
    int(0) 
    ["post_parent"]=> 
    string(0) "" 
    ["subpost"]=> 
    string(0) "" 
    ... and so on ... 
    } 
} 

我用來創建它的代碼如下:

$charity = new WP_Query(array(
    'post_type' => 'charity', 
    'order'  => 'ASC' 
)); 

我試過做很多<?php echo $charity[INSERTSOMETHINGHERE']; ?>的變化,沒有任何顯示。我不使用PHP,但我的客戶堅持使用WordPress網站。我將如何訪問該對象中的post_type之類的內容?

謝謝!

回答

3
$charity->query_vars['post_type'] 
+0

非常感謝! – Connor