• Hello Everyone,

    I am new to plugin development and am a little stuck with my current code. I am trying to just add some basic content after an individual full article.

    function dd_tiny_tweet_init(){
    	echo 'I'd like this to show up after the full post on a single.php page';
    }
    add_action('loop_end', 'dd_tiny_tweet_init');

    Obviously I am trying loop_end, which is replacing all of the post and replacing it with what is being printed. Can anyone point me in the right direction on how to append a plugin after an individual post? Any links or suggestions would be a huge help.

    Regards,

    Drew

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m pretty sure “loop_end” is going to be at the end of the loop, meaning that it’s going to happen after the entire loop – with all the posts – ends.

    You’re better off using “the_content” instead. It passes the body of the post along as an argument, so you can append like this:

    $mycontent .= dd_tiny_tweet_init()

    One additional note, using an “init” function doesn’t sound quite right. Maybe it’s just not the right thing to call it, but it’s all just personal preference.

    I’m not getting the effect you describe. I copied your code and pasted it unaltered into several different files and your text prints below my posts in all cases, leaving all the other text just like it is.

    DragonFlyEye is right though. It will print at the end of the whole loop not at the end of the individual posts. Since you want this to fire only when you have single posts that detail may not matter but the code you posted does nothing to insure that this fires only for single posts. Left as is this will echo text at the bottom of every pageful of posts.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add_action to end of individual post?’ is closed to new replies.