1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Wordpress help - adding text below main content

Discussion in 'PHP & Perl' started by dcuthbert, Sep 1, 2013.

  1. dcuthbert

    dcuthbert Regular Member

    Joined:
    Jun 15, 2011
    Messages:
    411
    Likes Received:
    249
    Hi,

    This is probably easy for someone who knows how to code, but unfortunately my skills aren't up to scratch!

    I want to add a single line of HTML below the content on every single post. In single.php I've tried adding it here:

    Code:
                        <div class="post-entry">
                            <?php the_content(); ?>
    MY CODE HERE              
                        </div><!-- /post-entry -->
    However, it then displays below my sharing plugin and related posts plugin. I want it to display directly below the content - above the sharing and related posts plugins.

    Any idea how I can do this? If it helps, I'm using the Max Magazine theme from Gazpo.

    Big thanks to anyone who can help with this!
     
  2. TheeAriGrande

    TheeAriGrande Regular Member

    Joined:
    Jul 14, 2013
    Messages:
    270
    Likes Received:
    151
    Location:
    Candlestick Park
    I'm not a big experienced Wordpress developer, but I'm pretty sure I know why the HTML isn't showing up before the post.

    Your plugins are hooking into the rendering of the page and is attaching the sharing buttons/relating posts the content. Find the "the_content" function and add the HTML there.

    The class for the "the_content" function is located in the post-template.php file. You'll probably have to add your HTML into one of the methods of the class. See this page: http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/post-template.php

    EDIT:

    The easiest way to do this is to create a plugin that'll hook into the system and add your HTML code after the content. That'll be easier and safer than editing any system files.

    Refer to this page: http://wordpress.org/support/topic/writing-a-plugin-how-do-i-add-html-after-the-content

    The code should look something like this:

    PHP:
    <?php

    function addContent($content) {
        
    $content .= '<a href="http://www.yahoo.com">yahoo</a>';
    return 
    $content;
    }   

     
    add_action('the_content''addContent');

    }

    ?>
     
    • Thanks Thanks x 1
    Last edited: Sep 1, 2013