1

The WordPress Social Login plugin contains a [wordpress_social_login] shortcode that can be used in posts and pages. The problem is, no matter where I place it in the body of the post, it always renders as the very first thing on the page. I am using the Salient theme and I have been looking through one of the plugin functions called wsl_render_login_form() which seems to render it but it isn't obvious how it is placing it on the page first.

How can you make the shortcode render where you actually place it? Seems like this should be the default but it is annoyingly not the case.

2
  • Very likely a duplicate of Shortcode outputs at the top of the_content
    – fuxia
    Aug 16, 2014 at 19:52
  • That is the same issue but I am not sure how to go about cleaning up this plugin's mess from my own plugin. The wsl_render_login_form() function contains these two highlighted lines that output the form content: l.adamfisher.me/1tamL2i
    – Adam
    Aug 16, 2014 at 20:11

1 Answer 1

3

If you have a function that you cannot change to prevent the premature output, you can still override the shortcode handler:

add_shortcode( 'wordpress_social_login', 'wordpress_social_login_fix' );

function wordpress_social_login_fix( $attributes, $content ) {
    ob_start();
    wsl_render_login_form();
    return ob_get_clean();
}
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.