2012-12-28 56 views
-6

如果在某個頁面上,Wordpress會在'換行'之前加載一個標題。根據條件重新排序HTML元素?

旗幟由包括文件「的header.php」

不過,我想「主包裝」後,加載它,如果它是一個不同的網頁上加載。

<body> 

    <div id="page-wrap"> 

     <div id="main-wrap"> 
     <div id="main-header"> 

     <?php include ("./../included/header.php"); ?> 
    </div> 

</div> 

我想通過創建一個包含備用header2.php文件的條件語句來解決這個問題。所以,問題由兩個單獨的文件解決。

+0

所以你只只喜歡展示的header.php當某些條件爲真? – Ivo

+0

使用'if else'語句。 – Sethen

+0

你不解釋你面臨的問題是什麼,除了只有滿足條件時才能放置。另一方面,「通過在身體標籤後面加載它」意味着什麼。將它加載到身體內還是在身體關閉標籤後加載? –

回答

0

使用if語句。使用兩條語句,以免重複出現橫幅。

<body> 
    <?php 
    if(yourcondition){ 
    include ("./../included/header.php"); 
    } 
    ?> 
    <div id="page-wrap"> 

     <div id="main-wrap"> 
     <div id="main-header"> 

    <?php 
    if(yourcondition){ 
    include ("./../included/header.php"); 
    } 
    ?> 
</div> 

1

使用只是if..else...這樣

<div id="main-header"> 
    <?php 
    if(condition) { 
     include ("./../included/header.php"); 
    } 
    ?> 
</div>