• I’m not real sure to explain this but I’ll try. I’m attempting to insert custom text into the bottom of my posts… sort of like a footer. An example can me found in this image. I’m referring to the Source and Coverage in the bottom.

    I’ve searched google and can’t find a solution. Also searched for a plugin with no luck.

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Insert it after <?php the_content(); ?> in your child theme‘s single.php. Or, you can also create a function then put it into function.php.

    //Insert info into bottom of posts
    function info_after_post($content){
    if (is_single()) {
    	$content .= '<p>Insert Your Info Here</p>';
    }
    	return $content;
    }
    
    add_filter( 'the_content', 'info_after_post' );

    Hi Zendon,

    Just copy and paste the following code into functions.php file of your theme:

    // Adding custom text after posts
    function add_custom_text_under_posts($content){
    if(is_single){
        $content.= '<hr />';
    // Replace the # with actual Links!
        $content.= '<ul>'.'<li>'.'Source: <a href="#">Battlefield Arenas</a>'.'</li>'.'<li>'.'More Coverage: <a href="#">Official Site</a>'.'</li>'.'<ul>';
    return $content;
                  }
       }
    
    add_filter('the_content','add_custom_text_under_posts');
    Thread Starter Zendon

    (@zendon)

    Thanks for the reply.

    So it seems as though I have a new problem. Whenever I try to edit an file I get the msg

    Warning: Cannot modify header information – headers already sent by (output started at /home/content/03/10627203/html/wp-content/themes/Grey/functions.php:1719) in /home/content/03/10627203/html/wp-includes/pluggable.php on line 876

    I’ve never experienced this before. I don’t have any new plugins. Not sure what could be causing this.

    Thread Starter Zendon

    (@zendon)

    I think I fixed it. Did a little research and apparently I had ?> in the wrong place.

    Moving back to the original issue. What part of the functions.php would I put that code into? I tried several place and it displays the code as text on the screen.

    Thanks

    You can place the code at the bottom of the functions.php file just before closing php tag that is “?>

    If there is no closing tag “?>” then no need to worry, just paste the code at the bottom of functions.php file.

    Thread Starter Zendon

    (@zendon)

    Okay, so the code worked. Only problem is, the source will be different on every blog that I post. Is there a way to change it for each?

    Yes You can make a shortcode, give the shortcode different attributes for different posts and that will work.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Insert info into bottom of posts’ is closed to new replies.