我创建了一个名为“文章”的自定义帖子类型,其功能与一般帖子类型相同;我使用相同的模板来显示这两个存档。
使用内置帖子的博客页面显示发布日期和发布时间,
Seen here
自定义帖子类型页面会忽略此信息
Seen here
我在这一点上迷路了,不知道我需要做什么,这是额外的,因为它使用相同的代码来显示两个页面。
这是post类型函数:
function post_type_articles() {
$labels = array(
\'name\' => _x( \'Articles\', \'Post Type General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'Article\', \'Post Type Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Articles\', \'text_domain\' ),
\'name_admin_bar\' => __( \'Article\', \'text_domain\' ),
\'archives\' => __( \'Article Archives\', \'text_domain\' ),
\'attributes\' => __( \'Article Attributes\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Parent Article\', \'text_domain\' ),
\'all_items\' => __( \'All Articles\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New Article\', \'text_domain\' ),
\'add_new\' => __( \'Add New Article\', \'text_domain\' ),
\'new_item\' => __( \'New Article\', \'text_domain\' ),
\'edit_item\' => __( \'Edit Article\', \'text_domain\' ),
\'update_item\' => __( \'Update Article\', \'text_domain\' ),
\'view_item\' => __( \'View Article\', \'text_domain\' ),
\'view_items\' => __( \'View Article\', \'text_domain\' ),
\'search_items\' => __( \'Search Articles\', \'text_domain\' ),
\'not_found\' => __( \'Not found\', \'text_domain\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\', \'text_domain\' ),
\'featured_image\' => __( \'Featured Image\', \'text_domain\' ),
\'set_featured_image\' => __( \'Set featured image\', \'text_domain\' ),
\'remove_featured_image\' => __( \'Remove featured image\', \'text_domain\' ),
\'use_featured_image\' => __( \'Use as featured image\', \'text_domain\' ),
\'insert_into_item\' => __( \'Insert into article\', \'text_domain\' ),
\'uploaded_to_this_item\' => __( \'Uploaded to this article\', \'text_domain\' ),
\'items_list\' => __( \'Articles list\', \'text_domain\' ),
\'items_list_navigation\' => __( \'Articles list navigation\', \'text_domain\' ),
\'filter_items_list\' => __( \'Filter articles list\', \'text_domain\' ),
);
$args = array(
\'label\' => __( \'Article\', \'text_domain\' ),
\'description\' => __( \'Article Description\', \'text_domain\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'author\', \'thumbnail\', \'comments\', \'trackbacks\', \'revisions\', \'custom-fields\', \'page-attributes\', \'post-formats\', ),
\'taxonomies\' => array( \'category\', \'post_tag\' ),
\'hierarchical\' => false,
\'public\' => true,
\'rewrite\' => array( \'slug\' => \'articles\' ),
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'menu_icon\' => \'dashicons-format-aside\',
\'show_in_admin_bar\' => true,
\'show_in_nav_menus\' => true,
\'can_export\' => true,
\'has_archive\' => \'articles\',
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'post\',
);
register_post_type( \'articles\', $args );
}添加\\u操作(\'init\',\'post\\u type\\u articles\',0);
这是回路
<header class="entry-header">
<?php
if ( is_singular() ) :
the_title( \'<h1 class="entry-title">\', \'</h1>\' );
else :
the_title( \'<h2 class="entry-title archive-header"><a href="\' . esc_url( get_permalink() ) . \'" rel="bookmark">\', \'</a></h2>\' );
endif;
if ( \'post\' === get_post_type() ) : ?>
<div class="entry-meta">
<?php factorypress_posted_on(); ?>
</div><!-- .entry-meta -->
<?php
endif; ?>
</header><!-- .entry-header -->
<div class="entry-content">
<div class="row">
<div class="col-sm-3">
<?php the_post_thumbnail(\'large\', array(\'class\' => \'img-responsive\')); ?>
</div><!-- /.col-sm-2 -->
<div class="col-sm-9">
<?php
the_content( \'more\', sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( \'Continue reading<span class="screen-reader-text"> "%s"</span>\', \'factorypress\' ),
array(
\'span\' => array(
\'class\' => array(),
),
)
),
get_the_title()
) );
wp_link_pages( array(
\'before\' => \'<div class="page-links">\' . esc_html__( \'Pages:\', \'factorypress\' ),
\'after\' => \'</div>\',
) );
?>
</div><!-- /.col-sm-10 -->
</div><!-- /.row -->
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php factorypress_entry_footer(); ?>
</footer><!-- .entry-footer -->
如果你能帮我回答这个问题,请提前感谢!