Adding "date modified" to twenty ten theme
-
I’m using the twenty ten theme and I want nothing more than “date modified” to show up in single posts to the right of “date posted” and “author” (to keep it simple I don’t need the Author who modified it). Is there a simple code and where do I insert it.
I didn’t include code or URL because it’s universal.
Thanks
Mr.R.
-
edit functions.php of the theme;
close to the end, find:
function twentyten_posted_on() { ..... .....change the function to something like:
function twentyten_posted_on() { printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ), 'meta-prep meta-prep-author', sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>', get_permalink(), esc_attr( get_the_time() ), get_the_date() ), sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>, date modified: %4$s', get_author_posts_url( get_the_author_meta( 'ID' ) ), sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ), get_the_author(), esc_attr( get_the_modified_date() ) ) ); }From the solving my own problems Dept.
In the single post editor (single.php) look for:
<div class="entry-meta"> <?php twentyten_posted_on(); ?>
</div><!-- .entry-meta -->
then add:
- Post updated on: <?php the_modified_date(); ?>
after the posted on tag to make:
<div class="entry-meta">
<?php twentyten_posted_on(); ?> - Post updated on: <?php the_modified_date(); ?></div><!-- .entry-meta -->
to the right of the section, – Post updated on August 01, 2010 will appear (it’s even remembers the date modified on all posts).
Thanks me!
Thank you for your help alchymyth! (I was posting at the same time as you.)
tried it your way alchymyth:
<b>Parse error: syntax error, unexpected T_FUNCTION, expecting ‘{‘ in D:\Hosting\6120655\html\wp-content\themes\2010-weaver\2010functions.php on line 499</b>
Uh oh!
i worked from the original default TwentyTen – 2010-weaver might have some modification in the code that are no more compatible with the original TwentyTen –
use your idea, seems to work great.
no reason why the changes would have triggered an error (typo?):
the actual changes were only in this part:sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>, date modified: %4$s', get_author_posts_url( get_the_author_meta( 'ID' ) ), sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ), get_the_author(), esc_attr( get_the_modified_date() )added this:
, date modified: %4$s'after</span>
and this:, esc_attr( get_the_modified_date() )afterget_the_author()(nothing complicated, and worked for TwentyTen )
Thanks, I sincerely appreciate your help. Do you have any suggestions as how I can recover my site? It’s a hobby more than anything. Since the problem is with the theme, can I change it in file manager or something? Thanks in advance if you have any help. WPWeaver is a twenty ten child theme.
if you suspect that the error is caused just by 2010functions.php, you can ftp a fresh copy (from the 2010weaver theme or from a backup) to the same location, overwriting the ‘faulty’ file.
(file manager should also work)If I go into file manager and just delete the theme can I get back to dashboard and put things back together?
if you haven’t made any substantial changes to your theme, deleting it in the file manager and uploading a fresh copy should work.
(i personally edit my themes local on my computer (dreamweaver) and ftp the changed files to the server; maybe a bit more complicated than editing the files from within wordpress, but dreamwweaver has some useful syntax higlighting and error checks; and this way i can always undo changes, if the site runs into an error)
i tend to forget the perils of editing code and getting errors, and making the site unaccessibel 🙁PS:
if you have deleted the 2010weaver, the site should go back to the default theme and should be usable. and you should be able to re-install and activate 2010weaver.thanks for the tip, I’ll try it.
I’m back up – thanks for your help. In conclusion an easy way to add a “modified” date to single posts is this:
http://wordpress.org/support/topic/adding-date-modified-to-twenty-ten-theme?replies=11#post-1625358
The topic ‘Adding "date modified" to twenty ten theme’ is closed to new replies.