I'm writing a simple shortcode that inserts HTML wherever I put a shortcode, i.e. [myHTML]
I'm using the shortcode in the middle of my text
But, for some reason it ALWAYS appears at the top of the page content
How do I stop this?
How do I make the content appear exactly where I put the shortcode?
It's really annoying!
Thanks
Omar
nofearinc
Member
Posted 7 months ago #
There is probably some caching issue, try using ob_* functions to wrap your shortcode (sample: https://tobymackenzie.wordpress.com/2010/02/28/wordpress-shortcodes/ )
thanks for the reply
not working for me
i read and followed instructions - no luck
this is my code:
<?php
/*
Plugin Name: My Plugin
Version: 1.0
Description: My Plugin
*/
add_shortcode( 'myplug', 'myplug' );
function myplug () {
ob_start();
?>
<div>Hello World</div>
<?php }
$fncReturn = ob_get_contents();
ob_end_clean();
return $fncReturn;
?>
I've over simplified to illustrate my point
The shortcode is put in the middle of text
But 'Hello World' still appears at the top
Where am I going wrong?
Thanks
Omar
i posted this question a long time ago
i'm still having the same problem!
is there anyway of controlling when the shortcode code executes?
for me the whole idea of using shortcodes is defeated :(
or am i missing something?