Here is a simplified version of the plugin. It does what it is supposed to do. It displays the modified time like Modified: February 23, 2016
.
<?php
/**
*/
function modified_date($content) {
$post = get_post();
if (is_page()) {
}
else {
$origdate = get_the_time();
$moddate = get_the_modified_time();
if ($origdate != $moddate) {
echo '<div class="mod" style="line-height: 1.2em; position: relative; text-align: right;"><strong>Modified:</strong> ';
echo the_modified_date();
echo '</div>';
}
}
return $content;
}
add_filter('the_content', 'modified_date');
?>
I have tried add_action
and add_shortcode
with adjustments. Both displayed the modified date on the post, but not in print.
I have tried many plugins to print my post, but none pick up the modified time. The latest plugin, I have used Print My Blog
displays everything I want to see in a print except the modified time. The easiest Print My Blog
configuration that works (again except for the modified time) is:
Print My Blog > Settings > Print Buttons > select Posts
Then Customize Buttons > select Print
Is there something that I am missing? Any help would greatly be appreciated.
2
Answers
Beware that in your function
if $origdate == $moddate
you are not returning anything and the page will be empty. It’s better toreturn $content
at the end of the function to make sure it returns a value.