Published Data and Modified Date
-
Hi, I hope someone can help me.
I wanted to display a modified date when there is a post revision. Otherwise, show only the published date if there is no modification. Playing with the code below shows the last modified data even though there is no post revisions.
How can I make it to show Published Date only when no revisions? The code doesn’t seem to work even using isset.
/* Replaces same named function in /inc/blog/blog-config.php */ function astra_post_date() { $format = apply_filters('astra_post_date_format', ''); $published = esc_html(get_the_date($format)); $modified = esc_html(get_the_modified_date($format)); $output = '<p class="posted-on">'; if (!empty($modified)) { $output .= 'Last Modified: <span class="updated" '; $output .= 'itemprop="dateModified">' . $modified . '</span>'; } else { $output .= 'Published: <span class="published" '; $output .= 'itemprop="datePublished">' . $published; $output .= '</span>'; } $output .= '</p>'; return apply_filters('astra_post_date', $output); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Published Data and Modified Date’ is closed to new replies.