Creating plugin, not showing up where I want it.
-
Hi, I’m just newly starting out, writing my first plugin. I’m trying to have something (Google +1 button) show up at the bottom of every post. I want it to appear below the posts, but only when the post is displayed in full on its own page.
Here’s my plugin’s code:
class plusOnePutter{ // This function echoes the code necessary for the header or footer public function addToHead(){ echo '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>'; } // This echoes the code necessary to display the actual button public function addButton($content){ return $content . '<br /><g:plusone></g:plusone>'; } } $myPlusOnePutter = new plusOnePutter(); if (is_single){ add_action('wp_head', array($myPlusOnePutter, 'addToHead')); add_filter('the_content', array ($myPlusOnePutter, 'addButton')); }
Problem is, the plugin runs after every bit of content is displayed and not just on single posts. Perhaps, I’m misunderstanding the meaning of is_single?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Creating plugin, not showing up where I want it.’ is closed to new replies.