我在頁面中有以下文本。正如你所看到的,我的簡碼在底部是正確的,但是在代碼運行時,我的簡碼的輸出插入到頁面的頂部,而不是跟隨其前面的內容。爲什麼我的短代碼在其他內容之前被執行?
<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]
這裏是function.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" />
感謝那個地方的回答 – Roman