Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #186310

    Hi,
    im looking for the code to insert an “Google plus button”. If i insert the script, the page has some conflict.
    Could you help me out?

    Greets,

    Jan

    #186391

    Hi Crippy!

    Where are you trying to insert the code? Can you please post the code here? You can insert it on a Text Block then switch to Text or HTML editor. If it doesn’t contain any php codes, it should work. Please use this plugin: http://wordpress.org/plugins/insert-javascript-css/

    Regards,
    Ismael

    #186431

    Hi, i’ve installed the plugin you told me.

    The code still don’t work:
    <div class=”g-plusone” data-size=”medium” data-href=”http://test.de”></div&gt;
    <script type=”text/javascript”>
    window.___gcfg = {lang: ‘de’};

    (function() {
    var po = document.createElement(‘script’); po.type = ‘text/javascript’; po.async = true;
    po.src = ‘https://apis.google.com/js/plusone.js&#8217;;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(po, s);
    })();
    </script>

    You can’t see it in the front end.

    #187022

    Hi!

    Add this at the end of functions.php:

    function custom_script_func( $atts , $content = null ) {
    	return '<div class="g-plusone" data-size="medium" data-href="http://test.de"></div><script type="text/javascript">window.___gcfg = {lang: "de"};(function() {var po = document.createElement("script"); po.type = "text/javascript"; po.async = true;po.src = "https://apis.google.com/js/plusone.js";var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s);})();</script>';
    }
    add_shortcode( 'custom_script', 'custom_script_func' );

    Then, you can simply call it by using the [custom_script] shortcode wherever you want (tested locally).

    If you want to add attributes or make it more advanced you can use this tool to generate it.

    Cheers!
    Josue

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Google Plus Button’ is closed to new replies.