繁体   English   中英

WordPress:无法使标题不显示在首页上

[英]WordPress: Can't get title to not display on home page

这应该很简单,但实际上并非如此。 在我主题的template / content-page.php中,我希望标题显示在除首页之外的所有页面上。 我尝试了此代码的各种版本,但没有任何效果。

<?php if ( !is_front_page() || !is_home() ) { ?>
    <header class="page-header">
        <h1 class="page-title"><?php echo get_the_title(); ?></h1>
    </header>
<?php } ?>

首先,我们不需要在the_title()函数中添加回显。 它将自动回显。

if ( !is_front_page() && is_home() ) {

    // Default homepage ( both the front page and the recent posts page){

   <header class="page-header">
        <h1 class="page-title"><?php the_title(); ?></h1>
    </header>

}

您真的需要这样做吗? 我在page.php文件中

<?php get_header();
$p = get_post();
?>
<div id="main">
   <div id="content">
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
         <h1 class='pageTitle'><?php the_title();?></h1>
         <p><?php the_content(__('(more...)')); ?></p>
         <hr>
      <?php endwhile; endif; ?>
   </div>
   <?php get_sidebar('Right Sidebar');?>
</div>
<?php get_footer(); ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM