Skip to content

Instantly share code, notes, and snippets.

@Glinkfr
Last active February 12, 2024 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Glinkfr/5a79bfb47f7af0f620a0d097b617bc46 to your computer and use it in GitHub Desktop.
Save Glinkfr/5a79bfb47f7af0f620a0d097b617bc46 to your computer and use it in GitHub Desktop.
Création d'un Shortcode pour afficher la date de la dernière modification d'un site WordPress
// création d'un Shortcode pour afficher la date en français de la dernière modification d'un site WordPress.
// ajoutez ensuite simplement le shortcode [lastupdatedate] à votre widget ou footer
function last_update(){
global $wpdb;
$wpdb->query("SET NAMES 'utf8', lc_time_names = 'fr_FR'");
$last_updates = $wpdb->get_results("SELECT DATE_FORMAT(MAX(post_modified), '%W %d %M %Y') as date_maj FROM $wpdb->posts WHERE
(post_type='post' AND post_status='publish') OR ( post_type='page' AND post_status='publish')");
foreach ($last_updates as $last_update){
return $last_update->date_maj;
}
}
add_shortcode ('lastupdatedate', 'last_update');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment