-
AuthorPosts
-
November 8, 2013 at 10:19 pm #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
November 9, 2013 at 6:44 am #186391Hi 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,
IsmaelNovember 9, 2013 at 9:38 am #186431Hi, 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>
<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>You can’t see it in the front end.
November 12, 2013 at 12:36 am #187022Hi!
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 -
AuthorPosts
- The topic ‘Google Plus Button’ is closed to new replies.
