2017-04-24 39 views
-1

此代碼來的主題,它的假設刪除頁眉和頁腳,但不這樣做。我可以添加什麼來使其工作?由於爲什麼不是這個PHP代碼刪除頁眉和頁腳?

我試着從以下頁面http://www.mobiletechrx.com/tuts3/刪除它,但它不會似乎沒有呈現這些元素。謝謝!

<?php 
/** 
* Template Name: No Header Or Footer Page 
*/ 
?> 
<?php get_header(); ?> 
<?php while (have_posts()) : the_post(); ?> 


<section style="background-image: url()" class="banner alternate_page"> 
    <div class="container"> 
    <div class="main_cap"> 
     <div class="caption"> 
     <h2> 
     </h2> 
     </div> 
    </div> 
    </div> 
</section> 

<section class="north_america default_page_with_sidebar"> 
    <div class="container"> 
    <div class="fullwidth_part"> 
     <?php the_content(); ?> 
    </div> 
    </div> 
</section> 

<section class="mobiletech_built mobiletech_built_cutom"> 
    <div class="container"> 
    <div class="title_2"> 
     <h2></h2> 

    </div> 
    <ul> 

    </ul> 
    </div> 
</section> 

<?php wp_reset_query(); ?> 
<?php endwhile; ?> 
<?php get_footer(); ?> 
+0

當我看一下網頁的HTML源代碼,你表明,它與<部分直接開始,以結束。所以我不明白你想要什麼。你能否以更好的方式解釋? – Peter

+0

我只想頁腳和頭去掉,如果這是HTML的id做快,但它的WordPress的,我不知道如何刪除它們。我粘貼的PHP文件是刪除頁眉和頁腳,只顯示身體,但它不工作。林沒有太多的專家在PHP中,對不起,如果我有點模糊。 –

+0

此模板可能是主題特定的。主題的頁眉和頁腳文件可能會檢查您正在使用的模板,並隱藏某些元素。你使用這個文件的原始名稱,它的主題是什麼?你可以發佈主題的名稱,如果它是公開可用的主題? – Matt

回答

2

你有<?php get_header(); ?>,並在那裏<?php get_footer(); ?> - 你能指望什麼 - 這些標籤都存在,包括頁眉和頁腳?

您可以刪除這些,但你必須確保仍然保持完整,有效的HTML頁面結構 - 尤其是header.php中還含有大量的「看不見」的東西,你所需要的。

0

您可以刪除<?php get_header(); ?><?php get_footer(); ?>分別作爲johannes建議刪除頁眉和頁腳。但請記住,<head>標籤包含在頭和<body><html>標籤都包含在頁眉和頁腳中。

您可以執行的操作是將HTML結構從header.php複製到<body>標記並粘貼到模板文件中。這同樣適用於頁腳,複製您在footer.php需要,並粘貼在主題文件的HTML結構。因此,這將是這個樣子:

<?php 
/** 
* Template Name: No Header Or Footer Page 
*/ 
?> 
<!-- This is the start of the contents copied from header.php --> 
<html> 
    <head> 
     <!-- Some Codes from your header.php--> 
     <?php wp_head();?> 
     <!-- Some scripts and styles--> 
    </head> 
    <body> 
    <!-- This is maybe the end of the contents copied from header.php --> 
    <?php while (have_posts()) : the_post(); ?> 
    <section style="background-image: url()" class="banner alternate_page"> 
     <div class="container"> 
     <div class="main_cap"> 
      <div class="caption"> 
      <h2> 
      </h2> 
      </div> 
     </div> 
     </div> 
    </section> 
    <!-- Some codes --> 
    <?php wp_reset_query(); ?> 
    <?php endwhile; ?> 
    <!-- Some of the contents copied from the footer.php. That includes the scripts called outside the wp_footer action hook and such.--> 
    <?php wp_footer();?> 
    </body> 
</html>