我已经创建了一个自定义帖子类型,但在类别存档页面上,帖子元信息不会显示。
这是用于显示post meta的代码:
<?php if ( \'post\' === get_post_type() ) codilight_meta_1();?>
这是上述函数的代码:
function codilight_meta_1() {
$time_string = \'<time class="entry-date published updated" datetime="%1$s">%2$s</time>\';
if ( get_the_time( \'U\' ) !== get_the_modified_time( \'U\' ) ) {
$time_string = \'<time class="entry-date published" datetime="%1$s">%2$s</time>\';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( \'c\' ) ),
esc_html( get_the_date() )
);
$posted_on = sprintf(
esc_html_x( \'%s\', \'post date\', \'codilight\' ),
\'<span class="entry-date">\' . $time_string . \'</span>\'
);
$byline = sprintf(
esc_html_x( \'%s\', \'post author\', \'codilight\' ),
\'<span class="author vcard"><a class="url fn n" href="\' . esc_url( get_author_posts_url( get_the_author_meta( \'ID\' ) ) ) . \'">\' . esc_html( get_the_author() ) . \'</a></span>\'
);
echo \'<div class="entry-meta entry-meta-1">\';
echo $byline.$posted_on;
if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo \'<span class="comments-link">\';
echo \'<i class="fa fa-comments-o"></i>\';
comments_popup_link( \'0\', \'1\', \'%\' );
echo \'</span>\';
}
echo \'</div>\';
}