WordPress.org

Ready to get started?Download WordPress

Forums

I'd like a standard footer on every article - is this possible? (6 posts)

  1. zascar
    Member
    Posted 5 years ago #

    I want to set something up on my blog, so that at the end of every article, there is a standard 'footer' with some generic information.

    I just want it to say something like "This artices was written by joe blogs who works for abc inc, he is an expert in xyz - contact him with any quereie etc etc

    Is there a plugin or some way of doing this?

    Thanks

  2. Roy
    Member
    Posted 5 years ago #

    If you have a look at your theme, in the index.php (and single.php, archive.php) it probably gives some code that says: "this post is written by author" (in code of course). Just look up that bit, see the fixed text (often "by") and edit it a little.
    I'm not the right person to talk you through the exact coding, but there you may have an idea what you're looking for.

  3. chaoskaizer
    Member
    Posted 5 years ago #

    Is there a plugin or some way of doing this?

    try the following code; add inside your theme's functions.php

    <?php
    function my_generic_carbon_footprint($content)
    {	global $wp_query;
    
    	if ($wp_query->is_singular){
    	$msg = __('This artices was written by joe who works for abc inc, he is an expert in xyz - contact him with any quereie et cetera');
    	$msg = '<p class="entry-footer">'.$msg.'</p>';
    	return $content.PHP_EOL.$msg;
    	} else {
    		return $content;
    	}
    }
    
    add_filter('the_content','my_generic_carbon_footprint');
    ?>
  4. Roy
    Member
    Posted 5 years ago #

    Hm, functions.php...
    Zascar, listen to Chaos, she's much better in CSS and PHP than I am. I work on trial-and-error, she on knowledge!

  5. terriann
    Member
    Posted 5 years ago #

    Instead of adding a function to your functions.php file I am inclined to agree with Gangleri and suggest you add it to the template.

    Just below where your single.php (for permalink pages) has <?php the_content(); ?> put what you want to display.

    <div class="postfoot">This post was by .....</div>

    If you don't have a single.php file in your theme, add it below <?php the_content(); ?> like this to limit it to permalink pages only:

    <?php if(is_single()): ?><div class="postfoot">This post was by .....</div><?php endif; ?>

    If you want it to display the name dynamically by the author of the post you use the author template tags. Like:

    <div class="postfoot">This post was by <?php the_author(); ?> is <?php the_author_description(); ?></div>

    I like using the author description cause it allows you to change the description in the admin interface in the profile.

  6. zascar
    Member
    Posted 5 years ago #

    Perfect thanks guys

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags