1

I'm using WordPress social login plugin shortcode [wordpress_social_login]. I want to put it in custom template file inside theme directory.

example:

<?php 
/*
Template Name: Social Login Page
*/
echo do_shortcode('[wordpress_social_login]');

so I create a blank page using this template, the rendering is ok but the button href become javascript:void(0); and it won't redirect.

i can't figure this out, so please help..

Thanks

1

You haven't included get_header() or get_footer() in your template. They will load header.php and footer.php which should include wp_head() and wp_footer(). Those last two functions are important because that's where scripts are loaded.

If your shortcode depends on a script being loaded in the header or the footer, then you need wp_head() or wp_footer(), thats where plugins load their scripts. Looking at the code for this plugin (tell me if that's not it), then the script for it loads in wp_head().

So at the very least your template needs to look like this:

<?php 
/*
Template Name: Social Login Page
*/
?>
<!DOCTYPE html>
<html>
<head>
    <?php wp_head(); ?>
</head>
<body>
    <?php echo do_shortcode('[wordpress_social_login]'); ?>
</body>
</html>

Looking at the plugin code, the only way it could've worked on your localhost is is you had not turned on the "popup" functionality, which requires the script.

Also, even if you're not using wp_head(), you still need the <html>,<head>, and <body> tags to be valid HTML.

  • but i don't want both the header and footer, just want a blank page. i tried this on my localhost and it's working, so dunno why – Hend Ry Aug 9 '17 at 11:59
  • I've updated my answer. – Jacob Peattie Aug 9 '17 at 12:10
  • 1
    ahh.. I see. ok, it's working now! Thanks Jacob for your time and explanation. #bighug – Hend Ry Aug 9 '17 at 12:20
1

you are using a wrong syntax of do_shortcode(). Check do_shortcode() page for more information.

echo do_shortcode['wordpress_social_login'];

Replace it with this:

echo do_shortcode('[wordpress_social_login]');

try it. I hope it's useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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