仅从主页中删除div类

时间:2013-03-30 23:36:23

标签: php html css wordpress

首先,我首先要说的是我不懂PHP。

我希望我的页脚显示在所有页面上(wordpress网站),现在不是问题。我想要的是

<div class="inner-footer-wrapper">

隐藏在主页上。

这是我在footer.php中的内容

    <div id="footer">
    <div class="inner-footer-wrapper">

    <?php if (!is_page_template("template-maintenance-page.php") && $super_options[SN."_footer_widgets"]=="Yes") : ?>
    <div class="container clearfix">  

    <?php 
    $footer_layout = $super_options[SN."_footer_layout"];
    switch($footer_layout)
    {
    case "two-col" : 

    echo '<div class="footer-cols one_half clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols one_half_last clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>"; 

    break;
    case "three-col" : 

    echo '<div class="footer-cols one_third clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols one_third clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>";

    echo '<div class="footer-cols one_third_last clearfix">';
    dynamic_sidebar ("Footer Column 3"); 
    echo "</div>"; 

    break;
    case "four-col" : 

    echo '<div class="footer-cols one_fourth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols one_fourth clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>";

    echo '<div class="footer-cols one_fourth clearfix">';
    dynamic_sidebar ("Footer Column 3"); 
    echo "</div>";

    echo '<div class="footer-cols one_fourth_last clearfix">';
    dynamic_sidebar ("Footer Column 4"); 
    echo "</div>"; 

    break;
    case "five-col" : 

    echo '<div class="footer-cols one_fifth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols one_fifth clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>";

    echo '<div class="footer-cols one_fifth clearfix">';
    dynamic_sidebar ("Footer Column 3"); 
    echo "</div>";

    echo '<div class="footer-cols one_fifth clearfix">';
    dynamic_sidebar ("Footer Column 4"); 
    echo "</div>";

    echo '<div class="footer-cols one_fifth_last clearfix">';
    dynamic_sidebar ("Footer Column 5"); 
    echo "</div>"; 

    break;
    case "six-col" : 

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>";

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 3"); 
    echo "</div>";

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 4"); 
    echo "</div>";

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 5"); 
    echo "</div>";

    echo '<div class="footer-cols one_sixth_last clearfix">';
    dynamic_sidebar ("Footer Column 6"); 
    echo "</div>"; 

    break;

    case "one-third" : 

    echo '<div class="footer-cols one_third clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols two_third_last clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>"; 

    break;
    case "one-fourth" : 

    echo '<div class="footer-cols one_fourth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols three_fourth_last clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>"; 

    break;
    case "one-fifth" : 

    echo '<div class="footer-cols one_fifth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols four_fifth_last clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>"; 

    break;
    case "one-sixth" : 

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols five_sixth_last clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>"; 

    break;


    }
    ?>

    </div>
    <?php endif; ?>
    </div>
    <div id="footer-menu">
    <div class="container clearfix">

    <p class="footer-text"><?php echo $helper->customFormat($super_options[SN."_footer_text"]); ?></p> 

    <?php  if(!is_page_template("template-maintenance-page.php") && $super_options[SN."_footer_menu"]=="Yes") : 
    if(function_exists("wp_nav_menu"))
    {
    wp_nav_menu(array(
    'theme_location'=>'footer_nav',
    'container'=>'ul',
    'depth' => 1
    )
    );
    }
    endif;
    ?>

    </div>      
    </div>
    </div>


    <script type="text/javascript">
    <?php 
    echo stripslashes($super_options[SN."_tracking_code"]);
    ?>
    </script>
    <?php  wp_footer();  ?>
    </body>
    </html>

我已经尝试过if is_home语句,但我没有足够的知识知道它的去向。有帮助吗?谢谢!

2 个答案:

答案 0 :(得分:1)

使用

包裹您不希望在主页上显示的所有内容
<?php if(!is_home()){?>

             //code here

<?php } ?>

或:

<div id="footer">
    <?php if(!is_home()){?>
    <div class="inner-footer-wrapper">

    <?php if (!is_page_template("template-maintenance-page.php") && $super_options[SN."_footer_widgets"]=="Yes") : ?>
    <div class="container clearfix">  

    <?php 
    $footer_layout = $super_options[SN."_footer_layout"];
    switch($footer_layout)
    {
    case "two-col" : 

    echo '<div class="footer-cols one_half clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols one_half_last clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>"; 

    break;
    case "three-col" : 

    echo '<div class="footer-cols one_third clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols one_third clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>";

    echo '<div class="footer-cols one_third_last clearfix">';
    dynamic_sidebar ("Footer Column 3"); 
    echo "</div>"; 

    break;
    case "four-col" : 

    echo '<div class="footer-cols one_fourth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols one_fourth clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>";

    echo '<div class="footer-cols one_fourth clearfix">';
    dynamic_sidebar ("Footer Column 3"); 
    echo "</div>";

    echo '<div class="footer-cols one_fourth_last clearfix">';
    dynamic_sidebar ("Footer Column 4"); 
    echo "</div>"; 

    break;
    case "five-col" : 

    echo '<div class="footer-cols one_fifth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols one_fifth clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>";

    echo '<div class="footer-cols one_fifth clearfix">';
    dynamic_sidebar ("Footer Column 3"); 
    echo "</div>";

    echo '<div class="footer-cols one_fifth clearfix">';
    dynamic_sidebar ("Footer Column 4"); 
    echo "</div>";

    echo '<div class="footer-cols one_fifth_last clearfix">';
    dynamic_sidebar ("Footer Column 5"); 
    echo "</div>"; 

    break;
    case "six-col" : 

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>";

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 3"); 
    echo "</div>";

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 4"); 
    echo "</div>";

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 5"); 
    echo "</div>";

    echo '<div class="footer-cols one_sixth_last clearfix">';
    dynamic_sidebar ("Footer Column 6"); 
    echo "</div>"; 

    break;

    case "one-third" : 

    echo '<div class="footer-cols one_third clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols two_third_last clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>"; 

    break;
    case "one-fourth" : 

    echo '<div class="footer-cols one_fourth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols three_fourth_last clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>"; 

    break;
    case "one-fifth" : 

    echo '<div class="footer-cols one_fifth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols four_fifth_last clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>"; 

    break;
    case "one-sixth" : 

    echo '<div class="footer-cols one_sixth clearfix">';
    dynamic_sidebar ("Footer Column 1"); 
    echo "</div>";

    echo '<div class="footer-cols five_sixth_last clearfix">';
    dynamic_sidebar ("Footer Column 2"); 
    echo "</div>"; 

    break;


    }
    ?>

    </div>
    <?php endif; ?>
    </div>
<?php } ?>
    <div id="footer-menu">
    <div class="container clearfix">

    <p class="footer-text"><?php echo $helper->customFormat($super_options[SN."_footer_text"]); ?></p> 

    <?php  if(!is_page_template("template-maintenance-page.php") && $super_options[SN."_footer_menu"]=="Yes") : 
    if(function_exists("wp_nav_menu"))
    {
    wp_nav_menu(array(
    'theme_location'=>'footer_nav',
    'container'=>'ul',
    'depth' => 1
    )
    );
    }
    endif;
    ?>
    </div>      
    </div>
    </div>
    <script type="text/javascript">
    <?php 
    echo stripslashes($super_options[SN."_tracking_code"]);
    ?>
    </script>
    <?php  wp_footer();  ?>
    </body>
    </html>

答案 1 :(得分:1)

在您的主页上

,将其放在正文标记中 -

<body <?php $page = "home"; ?>>

现在将它放在页脚标记中 -

<div class="inner-footer-wrapper" style="display:"<?php if($page == "home"){ echo "none";}?>">