2017-10-18 41 views
0

我想顯示我在wordpress博客上修改我的文章的時間。 我試圖找到的代碼,在這裏我發現了什麼在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'); 

,但我真的不知道如何將它應用到我的主題,代碼用於顯示時間公佈我的一個主題是像下面

<?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 } ?> 

,我TRID到修改代碼來此

<?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 } ?> 

我是新上php..can誰能幫助? btw即時通訊使用mythemeshop優勝美地主題

回答

1

你不需要第一組代碼(過濾器鉤子)。

打印出修改時間是這樣的:the_modified_time(get_option('date_format'))

+0

太感謝你了,它的工作原理..耶 – ChristyJ