Add a modified date in a wordpress post

Similar to my last post on how to add the author name in a wordpress post, here is one more trick for a multiuser blog. Sometimes, when you are managing website or blog, where multiple users can create or update posts, it is required to have an eye, who and when modified the post.

Some wordpress themes have this support inbuilt and some themes (like the default “Twenty-Eleven” theme or one of my current theme “Bridge” by Blank Themes) does not have this option.

This is what need to be done:

You will find a function, similar to bridge_posted_on() [replace bridge with your theme name] in your functions.php file. This function usually shows the Author name in the post. We will add a similar function below it. The function will look similar to the code below. You may need to do some modification according to the theme you are using.

function bridge_post_modified_on() {
printf( 'Last modified by <span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span> on %4$s',
get_author_posts_url( get_the_author_meta( 'ID' ) ),
sprintf( esc_attr__( 'View all posts by %s', 'bridge' ), get_the_author() ),
get_the_author(),
esc_attr( get_the_modified_date() )
);
}

 

Now, you will find a code similar to the code below, in your content-single.php file. This code brings the title of the blog with author and date info.

<header class="entry-header">
        <h1 class="entry-title"><?php the_title(); ?></h1>
        <div class="entry-meta">
             <?php bridge_posted_on(); ?>
        </div><!-- .entry-meta -->
</header>

Now, call the post_modified_on() function here, that you defined in the functions.php in the above step.

<div class="entry-meta">
    <?php bridge_posted_on(); ?> - <?php bridge_post_modified_on(); ?>
</div><!-- .entry-meta –>

This will show the date modified along with the post date like shown below:

Your Blog Title

Posted on June 14, 2012 by Subrat Pattnaik – Last modified by Another Author on August 8, 2012

You may also call the above function anywhere you want to show the modified date with the author info (like in a search page or archive list page).

Hope this helps.

Creating a full-width post in wordpress

WordPress provides wide range of templates [depending on the theme being used] for creating a page. However, there is no similar choice for posts. Now, you want the posts to appear full wide. Sometimes, you get the widgets appearing on either left or right (or both) side of the page, along with your post, although all the widgets are disabled.

To avoid this, you need to modify your theme files. This generally depends on the theme you are using. But I find that, every theme works on this parameter in almost similar way. Here, I am using the responsive theme and I will show how to do it for this particular theme.

The appearance for single page posts are controlled by single.php file present in the themes directory [wp-content\themes\responsive\single.php in my case].

Find the following code and comment it.

 php get_sidebar();

This is most possibly present towards the end of the file.

Now, if you refresh your page,  you will see the sidebar is removed. However, the page is still showing with 60-70% of screen width. That is because, the post is configured for showing about 60-70% of screen. For my theme, it is set something like:

 <div id="content" class="grid col-620">

In my style sheet, this value is set to somewhere areound 66%

.col-620 {
width:65.957446808511%;
}

Now, I will change the value to :

 <div id="content" class="grid col-940">

Where, the value “grid col-940” is defined in my style sheet as,

.col-940 {
width:100%;
}

That’s it. The page will now be showing in full width.

You may take similar approach to make the search page show in full width. The setting for the search page is present in search.php file inside your themes directory.