我有一页下面的文字。正如您所看到的,我的短代码位于底部,但当代码运行时,我的短代码的输出会插入到页面顶部,而不是跟随前面的内容。
<img class="alignnone" title="title_enquires" src="http://localhost/barcelona/wp-content/uploads/2011/08/title_enquires.jpg" alt="" width="589" height="77" />
<img class="alignnone" title="contact_map" src="http://localhost/barcelona/wp-content/uploads/2011/08/contact_map.jpg" alt="" width="555" height="222" />
[barcelona_address]
这是我在函数中注册的短代码。php文件:
<?php
add_shortcode( \'barcelona_address\', \'barcelona_shortcode_handler\' );
function barcelona_address_func()
{
print "<p>sdsdsds</p>";
}
function barcelona_shortcode_handler( $atts, $content=null, $code="" )
{
if (function_exists($code . "_func"))
{
call_user_func($code . "_func", $atts);
}
}
?>
结果是:
<p>sdsdsds</p>
<img class="alignnone" title="title_enquires" src="http://localhost/barcelona/wp-content/uploads/2011/08/title_enquires.jpg" alt="" width="589" height="77" />
<img class="alignnone" title="contact_map" src="http://localhost/barcelona/wp-content/uploads/2011/08/contact_map.jpg" alt="" width="555" height="222" />