Guest User

Untitled

a guest
Jan 18th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. Original code:
  2. -----------------------------------------------------------
  3. $output       .= '<span class="post-updated"> ' . $modified_on . '</span>';
  4.  
  5.  
  6.  
  7. Corrected code:
  8. -----------------------------------------------------------
  9. $output       .= '<span class="post-updated" itemprop="dateModified"> ' . $modified_on . '</span>';
  10.  
  11.  
  12.  
  13.  
  14. Complete code:
  15. -----------------------------------------------------------
  16. /**
  17.  * Display only last modified date in the post metadata.
  18.  *
  19.  * @param String $output Markup for the last modified date.
  20.  * @return void
  21.  */
  22. function your_prefix_post_date( $output ) {
  23.     $output        = '';
  24.     $format        = apply_filters( 'astra_post_date_format', '' );
  25.     $modified_date = esc_html( get_the_modified_date( $format ) );
  26.     $modified_on   = sprintf(
  27.         esc_html( '%s' ),
  28.         $modified_date
  29.     );
  30.     $output       .= '<span class="posted-on">';
  31.     $output       .= '<span class="post-updated" itemprop="dateModified"> ' . $modified_on . '</span>';
  32.     $output       .= '</span>';
  33.     return $output;
  34. }
  35. add_filter( 'astra_post_date', 'your_prefix_post_date' );
Add Comment
Please, Sign In to add comment