我的主页的循环中有变量,但当我尝试使用该行时$variable = $post->post_title; $variable = str_replace( \' - \', \'<br />\' ,$variable); echo $variable;
在具有相同循环的侧边栏中,标题将消失。
<?php
$recentPosts = new WP_Query();
$recentPosts->query(\'showposts=9&cat=191,2875,2574\');
?>
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
<?php $variable = $post->post_title; $variable = str_replace( \' - \', \'<br />\' ,$variable); echo $variable; ?>