2017-10-18 14 views
0

Je veux afficher l'heure où j'ai modifié mes articles sur le blog wordpress. J'ai essayé de trouver le code, et voici ce que j'ai trouvéAjouter l'heure de modification au contenu dans wordpress

function wpb_last_updated_date($content) { 
$u_time = get_the_time('U'); 
$u_modified_time = get_the_modified_time('U'); 
if ($u_modified_time >= $u_time + 86400) { 
$updated_date = get_the_modified_time('F jS, Y'); 
$updated_time = get_the_modified_time('h:i a'); 
$custom_content .= '<p class="last-updated">Updated on'. $updated_date . ' at '. $updated_time .'</p>'; 
} 

$custom_content .= $content; 
return $custom_content; 
} 
add_filter('the_content', 'wpb_last_updated_date'); 

mais je ne sais pas vraiment comment l'appliquer à mes thèmes, le code pour l'affichage du temps publié un mon thème est comme ci-dessous

<?php if(! empty($mts_options["mts_{$section}_headline_meta_info"]['date'])) { ?> 
<span class="thetime updated"><i class="fa fa-clock-o"></i> Published on <span itemprop="datePublished"><?php the_time(get_option('date_format')); ?></span></span> 
<?php } ?> 

et je Trid à modifier le code à ce

<?php if(! empty($mts_options["mts_{$section}_headline_meta_info"]['date'])) { ?> 
<span class="thetime updated"><i class="fa fa-clock-o"></i> Published on <span itemprop="datePublished"><?php the_time(get_option('date_format')); ?></span> Updated on <span itemprop="dateModified"><?php get_the_time(get_option('date_format')); ?></span></span> 
<?php } ?> 

je suis nouveau sur quelqu'un php..can aide? btw im utilisant des thèmes yosemite par mythemeshop

Répondre

1

Vous n'avez pas besoin du premier ensemble de code (le crochet de filtre).

Imprimez le temps modifié comme suit: the_modified_time(get_option('date_format'))

+0

Merci beaucoup, cela fonctionne .. yay – ChristyJ