移动你的短代码,请不要使用回声。 如果您在第一个示例中将简码放入文档中,它将始终浮动到顶部。如果我把它放在底部,它会出现在底部。
我的简码为[showpod]
CODE,你不能在任何场合
function makepod($atts) {
echo "<div class='podmysqlarray2 showpodholder'><h3 class='widget-title newposts'>Latest Snippets</h3>";
$args = array('numberposts' => '6');
$recent_posts = wp_get_recent_posts($args);
foreach($recent_posts as $recent){
echo '<div class="pod"><li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' . $recent["post_title"].'</a> </li> </div>';
}
echo "</div>";
}
add_shortcode('showpod', 'makepod');
AND NOW修改后的代码可以随时随地的地方: -
function makepod($atts) {
$cat = "<div class='podmysqlarray2 showpodholder'><h3 class='widget-title newposts'>Latest Snippets</h3>";
$args = array('numberposts' => '6');
$recent_posts = wp_get_recent_posts($args);
foreach($recent_posts as $recent){
$cat.= '<div class="pod"><li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' . $recent["post_title"].'</a> </li> </div>';
}
$cat .= "</div>";
return $cat;
}
add_shortcode('showpod', 'makepod');
请添加说明输出实际位置的HTML输出。 – hakre 2012-04-17 09:30:10
**注意mods **:这个问题*可能*更适合WPSE。 – 2012-04-18 18:14:35