2015-10-14 132 views
2

我使用Underscores.me框架製作WordPress主題。無法刪除WordPress頁面標題而不刪除內容

我不希望顯示在頁面的頁面標題。所以我想我可以利用一些簡單的CSS來做到這一點:

.entry-title {display:none;} 

但這樣做也刪除了相關網頁上的所有內容基本上只是顯示一個空白頁。

後來我想我可以在我的主題刪除這個去掉標題:

<header class="entry-header"> 
    <?php the_title('<h1 class="entry-title">', '</h1>'); ?> 
</header><!-- .entry-header --> 

但除去上述還會從顯示的所有內容。

它像標題是爲了展示內容顯示。我以前從未遇到過這個問題,並且我已經用Underscores.me開發了一些主題。但它就像新版本必須顯示頁面標題才能顯示內容。

有沒有人知道該怎麼辦?

我在本地主機上運行,​​所以我不能證明我的問題,但我使用了最新的主題從Underscores

即使我安裝一個「禁用頁面標題」插件插件禁用冠軍時,也刪除內容。

我真的很希望有人有過這個問題! :)

額外的信息:

這是page.php文件看起來的樣子:

<div id="primary" class="content-area"> 
    <main id="main" class="site-main" role="main"> 

     <?php while (have_posts()) : the_post(); ?> 

      <?php get_template_part('template-parts/content', 'page'); ?> 

      <?php 
       // If comments are open or we have at least one comment, load up the comment template. 
       if (comments_open() || get_comments_number()) : 
        comments_template(); 
       endif; 
      ?> 

     <?php endwhile; // End of the loop. ?> 

    </main><!-- #main --> 
</div><!-- #primary --> 

這是它要求的模板:

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
<header class="entry-header"> 
    <?php the_title('<h1 class="entry-title">', '</h1>'); ?> 
</header><!-- .entry-header --> 

<div class="entry-content"> 
    <?php the_content(); ?> 
    <?php 
     wp_link_pages(array(
      'before' => '<div class="page-links">' . esc_html__('Pages:', 'open2day'), 
      'after' => '</div>', 
     )); 
    ?> 
</div><!-- .entry-content --> 

正如我所說的,如果我用CSS刪除標題,它也刪除了內容。

+0

最後一個模板,內容page.php文件,丟掉了最後

,它一直是你的複製/粘貼錯誤,或者這是真的在模板中缺少什麼? – ThemesCreator

+0

嘗試僅評論具有'the_title()'的PHP命令。也就是說,不要刪除它周圍的'

'標籤;只是註釋掉PHP命令。 – PaulJ

+0

@ThemesCreater不會丟失我只是忘了複製/粘貼 – user3414678