我正在尝试将单个帖子的帖子标题作为'terms'的值:
<?php
$term = get_the_title();
query_posts(array(
'post_type' => 'referenzen',
'tax_query' => array(
array (
'taxonomy' => 'referenzen-kategorie',
'field' => 'slug',
'terms' => '{$term}',
)
),
'showposts' => 7
) );
?>
说明:单个帖子标题与自定义帖子类型'referenzen'的某些帖子的术语相对应,并且有多个带有相应术语的帖子,例如:Design&Production->我正在尝试传递单个将标题“设计与生产”发布到“条款” =>“设计与生产”。
尝试此代码。希望它对您有用。
<?php
global $post;
$term = $post->post_name;
query_posts(array(
'post_type' => 'referenzen',
'tax_query' => array(
array (
'taxonomy' => 'referenzen-kategorie',
'field' => 'slug',
'terms' => array($term),
)
),
'showposts' => 7
) );
?>