在我們的示例中,在該系列的這一部分中,在本系列的這一部分中,
。此20被投入到整數上,因為post_statuspost__in參數以獲取帖子的參數,wordpress仍然會獲取粘性帖子,即使它們不在您的列表中,如上圖中所示。要省略它們,您使用此代碼中的post__in和post_type參數僅查詢頁面。
>在上面的某些示例中,我使用post_type通常將您設置為任何
自定義帖子類型
$args = array(<br> 'post_type' => 'page'<br>);<br>
不是而不是不是register_post_type()
adminus menus中使用的標題。因此,假設您使用 register_post_type()
post_type<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">function register_product() {<br><br> $args = array(<br> 'name' => __( 'Products', 'tutsplus' ),<br> 'singular_name' => __( 'Product', 'tutsplus' )<br> );<br><br> register_post_type( 'product', $args );<br>}<br></pre><div class="contentsignin">登入後複製</div></div>
<cody>'<code>'<code>'post_type <p> <code>post_type
'Product'
>'Products'
>'product''product'
:
$args = array(<br> 'post_type' => 'product'<br>);<br>
post_status
默認情況下,如果您嘗試運行附件查詢,則它將無法正常工作。這是因為WordPress將附件的 POST_STATUS <code>inherit
設置為 sasenit <code>WP_Query
和 wp_query <ance> defaults默認為<code>'post_status'=&gt; '發布'<code>'post_status' => 'publish'
,除非您另行指定。因此,如果您想查詢附件,則必須 post_status<em>參數包括:<code> post_status
:post_status
$args = array(<br> 'post_type' => 'attachment',<br> 'post_status' => 'inherit'<br>);<br>
any <code>而不是<code> senasit <code> sasenit <ancenit>。我做了很多事情。從這裡的示例中您可以看到,有很多可能性:<p><code>any
inherit
使用它查找網站中的頂級頁面。 > page。 WP_Query
以上是wp_query參數:帖子,頁面和發布類型的詳細內容。更多資訊請關注PHP中文網其他相關文章!