繁体   English   中英

Wordpress query_posts多个变量不起作用

[英]Wordpress query_posts for Multiple variable not working

我试图获取具有category和自定义分类法Type的帖子的结果。 我正在尝试

$args = 'category=' . $cat . '&Type='.$type.'&order=ASC';
  query_posts($args);

我正在从GET请求中接收$cat$type 问题是,它被拉起属于所有职位Type分类ireespective到category

感谢您的帮助。

谢谢 !

我必须这样做:

$args = array(
    'post_type' => 'post',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'category',
            'field'    => 'slug',
            'terms'    => array($cat),
        ),
        array(
            'taxonomy' => 'Type',
            'field'    => 'slug',
            'terms'    => array( $type ),
        ),
    ),
);
$query = new WP_Query( $args );

而不是使用query_posts()

谢谢!

你可以试试这个吗

  $args = 'cat=' . $cat . '&post_type='.$type.'&order=ASC';
  query_posts($args);

有关更多参考: https : //codex.wordpress.org/Function_Reference/query_posts

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM