在我们的示例中,在该系列的这一部分中,在本系列的这一部分中,
。此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<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>
<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中文网其他相关文章!