簡體   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