【发布时间】:2012-01-25 15:59:36
【问题描述】:
我有从特定标签生成随机帖子的代码,
global $post;
$postid = $post->ID;
$args = array(
'orderby' => 'rand',
'showposts' => 10,
'tag' => 'ABC',
'post__not_in' => array($postid)
);
query_posts($args);
echo '<ul>';
while (have_posts()) : the_post();
echo '<li><a href="'.get_permalink().'" title="'.the_title('','',false).'">'.the_title('','',false).'</a></li>';
endwhile;
echo '</ul>';
这里的标签是“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 '<ul>';
while (have_posts()) : the_post();
echo '<li><a href="'.get_permalink().'" title="'.the_title('','',false).'">'.the_title('','',false).'</a></li>';
endwhile;
echo '</ul>';
这样不行,有人能解释一下为什么会这样吗?
【问题讨论】: