php - 自定义分类 WP_Query

标签 php mysql wordpress

我正在尝试显示具有自定义分类法的自定义帖子类型,但我没有任何运气。什么都没有出现。感谢您的帮助。

帖子类型 = 图库

自定义分类 slug = photoarea

我要显示的'photoarea' = fourth

enter image description here

<?php 

$args = array( 
               'post_type' => 'gallery', 
               'tax_query' => array(
                   array(
                        'taxonomy' => 'photoarea',
                        'field' => 'fourth', 
                        )
                ),
               'posts_per_page' => 10,
              );

$the_query = new WP_Query( $args );


if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();

     the_post_thumbnail();

 endwhile; endif;

wp_reset_query();

?> 

最佳答案

您可以使用以下代码片段:

$the_query = new WP_Query( 'post_type=gallery&photoarea=fourth');

然后是你的 while 循环。

关于php - 自定义分类 WP_Query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18283391/

相关文章:

php - 用于客户端下载的 WHMCS Hook ?

使用oop的PHP表单提交

mysql - 如何引用更新语句的 "set"部分中正在更新的表?

php - 一起使用 CSS 和 PHP

wordpress - git pre-receive hook 拒绝 heroku

php - Symfony Elasticsearch准则

javascript - Proxy.php 无法使用 AJAX Solr 工作

php - 通知 : Undefined index, php

php 在该间隔日期内显示通知

php - 我可以 "echo"从 wordpress 站点到子域站点的最新消息吗?