嗨,我想按术语显示帖子。首先,代码显示所有帖子:
$aProjectArgs = array(
\'post_type\' => \'uni_project\',
\'posts_per_page\' => -1,
\'orderby\' => \'menu_order\',
\'order\' => \'asc\'
);
因此,我添加了另一部分代码来按术语显示帖子:
$aProjectArgs = array(
\'post_type\' => \'uni_project\',
\'posts_per_page\' => -1,
\'orderby\' => \'menu_order\',
\'order\' => \'asc\'
\'tax_query\' => array(
array(
\'taxonomy\' => \'post_tag\',
\'field\' => \'id\',
\'terms\' => 43
)
)
);
但它不工作,它给我一个错误消息
:Parse error: syntax error, unexpected \'\'tax_query\'\'
有人能帮我吗?
SO网友:Umer Shoukat
用此代码替换您的代码。
$aProjectArgs = array(
\'post_type\' => \'uni_project\',
\'posts_per_page\' => -1,
\'orderby\' => \'menu_order\',
\'order\' => \'asc\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'post_tag\',
\'field\' => \'id\',
\'terms\' => 43
)
)
);