How to get snippets to show up on Posts only, not pages
-
Hi, I’d like to have the last updated snippet appear only on posts. I saw a previous post regarding this and tried adding the code mentioned there (see below), but it doesn’t seem to work. I tried the new code at the top and at the bottom of the last updated code…
add_action( ‘wp_head’, function () {
if ( ! is_single() ) { return; } ?> <style> /* css code here */ </style> <?php
} );
function show_last_modified_date( $content ) {
$original_time = get_the_time(‘U’);
$modified_time = get_the_modified_time(‘U’);
if ($modified_time >= $original_time + 86400) {
$updated_time = get_the_modified_time(‘h:i a’);
$updated_day = get_the_modified_time(‘F jS, Y’);
$modified_content .= ‘Last updated: ‘. $updated_day . ”;
}
$modified_content .= $content;
return $modified_content;
}
add_filter( ‘the_content’, ‘show_last_modified_date’ );
- The topic ‘How to get snippets to show up on Posts only, not pages’ is closed to new replies.