Shortcode is displaying in the wrong place
-
I have written a shortcode to include the contents of a php file in my posts but no matter where I place the shortcode, it always displays at the top of the post before the title. Here is the code added to my functions.php:
function inline() { return include (TEMPLATEPATH . '/inline.php');; } add_shortcode('in', 'inline');
I’ve also tried:
function inline() { global $content; $output = include ( TEMPLATEPATH . '/inline.php' ); return $output; } add_shortcode('in', 'inline');
It doesn’t seem to matter what the contents of my inline.php file are I’ve tried changing it to a number of things from just text to js but nothing changes. It appears to the the fact that I’m returning the php include function. When I change the return to be ‘hello’ then it displays in the correct place, but when I change it back to the include statement it jumps to the top of the post.
Most of the people I have seen with this problem have it because they are using “echo” instead of “return” but I’m not. I found a couple of posts by other people but their solutions make no sense to me.
Like this for example, doesn’t make sense to me. I tried it anyway and it didn’t work.
Please help!
- The topic ‘Shortcode is displaying in the wrong place’ is closed to new replies.