获取自定义帖子类型标题/名称

时间:2016-06-03 作者:Juliver Galleto

我正在使用自定义帖子类型并使用此plugin 要显示我的自定义帖子类型的存档,是否有人知道如何显示我的自定义帖子类型的名称/标题。php?

下面是存档。php

<?php
/**
 * The template for displaying all single posts and attachments
 *
 * @package WordPress
 * @subpackage Twenty_Fifteen
 * @since Twenty Fifteen 1.0
 */

get_header(); ?>
 <!-- **Main - Starts** --> 
<div id="main">
    <div class="parallax full-width-bg" style="background: #ffffff;">
        <div class="container">
            <div class="main-title">
                <h1><?php the_archive_title( \'<h1 class="page-title">\', \'</h1>\' ); ?></h1>
                <p style="color:#dddddd;font-size:13px;font-style:italic;margin: 5px 0px 0px 0px;"><?php the_archive_description( \'<div class="taxonomy-description">\', \'</div>\' ); ?></p>
             </div>
        </div>
    </div>  
    <div class="container">
        <!-- Primary Starts -->
        <?php if ( have_posts() ) : ?>
        <section id="primary" class="with-right-sidebar page-with-sidebar">
            <div class="dt-sc-margin30"></div>
             <?php while ( have_posts() ) : the_post();
                get_template_part( \'content-archive\', get_post_format() );
            endwhile;?>
            <div class="dt-sc-margin80"></div>
            <div class="dt-sc-margin80"></div>
        </section> <!-- **Primary - Ends** -->
        <?php get_sidebar(); ?>
        <?php else :
            get_template_part( \'content\', \'none\' );
        endif; ?>  
    </div>
</div>
<?php 
wp_footer();
get_footer();
?>

1 个回复
最合适的回答,由SO网友:TheDeadMedic 整理而成

You can use post_type_archive_title( $prefix = \'\', $display = true ):

<h1><?php post_type_archive_title() ?></h1>