07/15/2014 at 8:53 am
#297008
Keymaster
@ Craig
Yes, this would put text on the page, apologies for not pointing that out!
I took a quick look at your tweak, looks like you have an extra angle bracket on the hatom-extra
line. This fixes it:
//mod content
function hatom_mod_post_content ($content) {
if ( in_the_loop() && !is_page() ) {
$content = '<span class="entry-content">'.$content.'</span>';
}
return $content;
}
add_filter( 'the_content', 'hatom_mod_post_content');
//add hatom data
function add_mod_hatom_data($content) {
$t = get_the_modified_time('F jS, Y');
$author = get_the_author();
$title = get_the_title();
if ( is_single() || is_page()) {
$content .= '<div class="hatom-extra" style="display:none;visibility:hidden;"><span class="entry-title">'.$title.'</span> was last modified: <span class="updated"> '.$t.'</span> by <span class="author vcard"><span class="fn">'.$author.'</span></span></div>';
}
return $content;
}
add_filter('the_content', 'add_mod_hatom_data');
I was just about to hit the submit button to post my reply…
I really do not like the entry-content
span that is being applied … if your content has any block level HTML elements then HTML code is invalid. A better solution (as long as the theme is using the post_class()
function like they should be) would be this:
//mod content
function hatom_mod_post_content ($content) {
if ( in_the_loop() && !is_page() ) {
$classes = 'entry-content';
}
return $classes;
}
add_filter( 'post_class', 'hatom_mod_post_content');
//add hatom data
function add_mod_hatom_data($content) {
$t = get_the_modified_time('F jS, Y');
$author = get_the_author();
$title = get_the_title();
if ( is_single() || is_page()) {
$content .= '<div class="hatom-extra" style="display:none;visibility:hidden;"><span class="entry-title">'.$title.'</span> was last modified: <span class="updated"> '.$t.'</span> by <span class="author vcard"><span class="fn">'.$author.'</span></span></div>';
}
return $content;
}
add_filter('the_content', 'add_mod_hatom_data');