最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How can I display the last updated post with the author, the created date, and the modified date on one line?

programmeradmin1浏览0评论

If I understand well there is already include in wp /general-template.php, and this should include the function to display the updated date (I still want the original date).

I found this:

if ( !function_exists( 'get_the_modified_time' ) ) { 
    require_once ABSPATH . WPINC . '/general-template.php'; 
} 
$d = ''; 
  
// Optional. Post ID or WP_Post object. Default current post. 
$post = null; 
  
// NOTICE! Understand what this does before running. 
$result = get_the_modified_time($d, $post); 

So I tried to paste this piece of code in the template's content.php:

article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php
    if ( is_sticky() && is_home() ) :
        echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
    endif;
    ?>
  
    
    <header class="entry-header">
        <?php
        if ( 'post' === get_post_type() ) {
            echo '<div class="entry-meta">';
            if ( is_single() ) {
                twentyseventeen_posted_on();
            } else {
                echo twentyseventeen_time_link();
                twentyseventeen_edit_link();
            };
            echo '</div><!-- .entry-meta -->';
        };

        if ( is_single() ) {
            the_title( '<h1 class="entry-title">', '</h1>' );
        } elseif ( is_front_page() && is_home() ) {
            the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
        } else {
            the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
        }
        
        
        ?>
  <?php
        if ( !function_exists( 'get_the_modified_time' ) ) { 
    require_once ABSPATH . WPINC . '/general-template.php'; 
} 
$d = ''; 
  
// Optional. Post ID or WP_Post object. Default current post. 
$post = null; 
  
// NOTICE! Understand what this does before running. 
$result = get_the_modified_time($d, $post); 
    ?>

The only result I get is a blank page with only my article title displayed.

Maybe I'm completely wrong. If someone can help me with this problem that will be great.

发布评论

评论列表(0)

  1. 暂无评论