我有从特定标记生成随机帖子的代码,
global $post;
$postid = $post->ID;
$args = array(
'orderby' => 'rand',
'showposts' => 10,
'tag' => 'ABC',
'post__not_in' => array($postid)
);
query_posts($args);
echo '
- ';
while (have_posts()) : the_post();
echo '
'.the_title('','',false).'';endwhile;
echo '
';这里的标签是'ABC',但是当我将ABC存储在一个变量中时,$tagABC = 'ABC';然后在这里调用变量
global $post;
$postid = $post->ID;
$args = array(
'orderby' => 'rand',
'showposts' => 10,
'tag' => $tagABC,
'post__not_in' => array($postid)
);
query_posts($args);
echo '
- ';
while (have_posts()) : the_post();
echo '
'.the_title('','',false).'';endwhile;
echo '
';它不以这种方式工作,有人可以解释为什么这样吗?