return unformatted content in encosing shortcode

The <br /> tags are being added to the content by the wpautop() function. If you run your shortcode before it runs they will not be there. It is added in \wp-includes\default-filters.php with the default priority of 10. add_filter( ‘the_content’, ‘myshortcode’, 1 ); function myshortcode( $atts, $content = null ) { return $content; } wpautop() … Read more

Create shortcode to echo javascript

First of all, it looks like you are trying to enqueue version 2.2.4 of jquery, under the condition that jquery has already been loaded. That doesn’t look good. Secondly, you can’t just echo a script in a shortcode. You must add it to another script using wp_add_inline_script. Like this: function wpse238227_custom_shortcode23() { wp_enqueue_script(‘script-typed’, ‘https://www.example.comwp-content/themes/mediso-v1-03/typed.js’, array(‘jquery’)); … Read more

Shortcode to show the code

get_footer() echos the contents of the footer.php file. add_shortcode() requires that the callback return the contents of the shortcode and not echo it. I suppose you could do something like this if you really want. function show_footer() { ob_start(); get_footer(); return ob_get_clean(); } add_shortcode( ‘show_f’, ‘show_footer’ );

Shortcode output appearing at the top of the page only [duplicate]

Shortcode callback should return it’s output and not echo it. Something like this should work just fine: function get_loggedin_avatar (){ global $current_user; $result=””; if ( is_user_logged_in() ) { get_currentuserinfo(); $result=”<a href=”https://wordpress.stackexchange.com/myaccount”>”. get_avatar( $current_user->ID, 96, left ). ‘</a>’; } return $result; } add_shortcode( ‘loggedinavatar’, ‘get_loggedin_avatar’ );

Shortcode not showing anything

As birgire mentioned in the comments, “you’re missing the return part” to which you replied “how do I add that without escaping the HTML code?” EDIT: Just a clarification. Your code should have worked, as pointed out by dswebsme. I just tested with and without a return, and both work (although returning would be preferred). … Read more

show shortcodes in editor

Having stumbled across this (really late), here is the answer as posted on the wordpress forum by MichaelH: <?php global $shortcode_tags; echo “<pre>”; print_r($shortcode_tags); echo “</pre>”; ?> Putting it here so anyone searching here might find it.