WordPress查询按标记搜索
我目前正在从事一个用wordpress实现的项目。我想能够使用标签搜索自定义帖子 我试过:WordPress查询按标记搜索,wordpress,Wordpress,我目前正在从事一个用wordpress实现的项目。我想能够使用标签搜索自定义帖子 我试过: $query = new WP_Query( 'tag=' . $tag ); 但是没有邮件被退回 谢谢试试这样的 <?php $args=array( 'tag__in' => array(87),//replace with your tag id 'post_type' => 'custom'//replace with your custom post type );
$query = new WP_Query( 'tag=' . $tag );
但是没有邮件被退回
谢谢试试这样的
<?php
$args=array(
'tag__in' => array(87),//replace with your tag id
'post_type' => 'custom'//replace with your custom post type
);
query_posts($args));
?>
如果它是一个自定义的post类型,那么您必须添加post\u类型
参数
$args = array( 'post_type' => 'your_custom_post_typy', 'tag' => $tag );
$query = new WP_Query( $args );
另外,请确保您在register\u post\u type
中使用了'taxonomies'=>array('post\u tag')
?我看到您建议使用标记id,如果我将站点从开发环境移动到生产环境,它会起作用吗?或者我需要修改文件吗?