php - Why does my shortcode get executed before other content? -


i have following text in page. can see shortcode right @ bottom somehow when code runs, output of shortcode inserted @ top of page instead of following preceding content.

<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] 

here short code registration inside function.php file:

<?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);    } } ?> 

and result is:

<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" /> 

your shortcode handler supposed return output display in place of shortcode, not output itself.

http://codex.wordpress.org/shortcode_api


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -