1
我有一個生成從特定的標籤隨機職位代碼,存儲在一個變量標籤,PHP
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>';
它不以這種方式工作,可能有人解釋爲什麼會這樣呢?
我發現錯誤:)謝謝:) 問題不在那裏 –