How to add code to end of every post

Community Forums Forums Design Tips and Tricks How to add code to end of every post

This topic is: not resolved

This topic contains 5 replies, has 3 voices, and was last updated by  Pinky 2 years, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #27200


    I’m wanting to automatically add AdSense code to the end of each post in the future without having to manually add it to each post.

    I’ve tried a few of the simple hook options that I thought might work, but they didn’t place it in the correct place. I want it to display within the post content above the category and tag listings for that post – is one of the hooks set up for that?

    The site is if that helps.



    I’ve just done a quick search for a plugin to do that, and there seem to be a few…

    Take a look at this G search:


    You could use the code similar to adding a signature image to the end of posts

    // Add Signature Image after posts
    add_action(‘genesis_after_post_content’, ‘custom_include_signature’, 1);
    function custom_include_signature() {
     { ?>
     &lt;img src=&quot;<a href=";quot" rel="nofollow">;quot</a>; alt=&quot;your image name here&quot; /&gt;
    &lt;?php }}


    I also find this page is really valuable and has helped me work things out :


    Hopefully that helps a little





    Install the Genesis Simple Hooks plugin and paste in your Adsense code in any genesis_hook location.

    <?php if (is_single() ) { ?>
    <?php } ?>

    Change the conditional tag if needed.

    Or you can use a custom function:

    add_action(‘genesis_after_post_content’, ‘adsense_after_posts’);
    function adsense_after_posts() {
    if (is_single() )
        echo ‘<div class="adsense-style">Adsense goes here</div>';



    Hi guys,

    Thanks for that – I hadn’t seen that visual hooks guide before. I tried out the genesis_post_content and that seems to be just what I need. I’d assumed by the title that it would place the code at the beginning of the post but it adds it to the end of the post.



    You may need to reposition the post meta if you want your ads displayed before those links.



    Glad it was helpful – I have that page and a few others in my bookmarks tab for quick reference



Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.