doulun0651 2014-08-20 12:51
浏览 38

在Wordpress上的某些页面上删除侧栏

I am trying to edit a Worpress template. Everything work as as expected except that I wish to have a page without sidebar - which is not included in that template.

To achieve this I went to the template's folder, duplicated the "page.php" and named it page-nosidebar.php. Over there I deleted the get_sidebar call script. Here is how it looks like now:

<?php /*
    Template Name: No Sidebars
*/ ?>

<?php get_header(); ?>  
    <div id="single_cont">

        <div class="single_left">

            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>          
                <h1 class="single_title"><?php the_title(); ?></h1>
                <div class="single_inside_content">
                <?php the_content(); ?>
                </div><!--//single_inside_content-->
                <br /><br />
                <?php //comments_template(); ?>
            <?php endwhile; else: ?>
                <h3>Sorry, no posts matched your criteria.</h3>
            <?php endif; ?>                    

        </div><!--//single_left-->



        <div class="clear"></div>

    </div><!--//single_cont-->

<?php get_footer(); ?>

After this, I went to the page editor and assigned this new template to the page I wanted to have no sidebar. Problem? Sidebar still shows up.

How should I do? Thanks in advance!

UPDATE

footer.php

<div class="clear"></div>   

    <div id="footer">
       <div class="footer_text"> <?php echo date("Y"); ?> Company. Powered by <a href="http://www.site.se">Company</a></div>
       </div><!--//footer-->

    </div><!--//main_container-->

<?php wp_footer(); ?>

</body>

</html>

header.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head>  <link href='http://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Raleway:400,100,200' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Cabin:700' rel='stylesheet' type='text/css'>   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>    <title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>             <?php wp_head(); ?>   <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />   <!--[if lt IE 9]>   <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script> <![endif]-->                 <!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>--> <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery-latest.js"></script>   <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/scripts.js"></script>   <script src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.infinitescroll.js" type="text/javascript" charset="utf-8"></script>       <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" title="no title" charset="utf-8"/>    <script type="text/javascript"> $(document).ready( function($){   $('#content_inside').infinitescroll({

    navSelector  : "div.load_more_text",            
                   // selector for the paged navigation (it will be hidden)
    nextSelector : "div.load_more_text a:first",    
                   // selector for the NEXT link (to page 2)
    itemSelector : "#content_inside .home_post_box"
                   // selector for all items you'll retrieve   },function(arrayOfNewElems){

    $('.home_post_box').hover(      function() {            $(this).find('.home_post_text').css('display','block');         },      function () {           $(this).find('.home_post_text').css('display','none');      }   );  

      //$('.home_post_cont img').hover_caption();

     // optional callback when new content is successfully loaded in.

     // keyword `this` will refer to the new DOM content that was just added.
     // as of 1.5, `this` matches the element you called the plugin on (e.g. #content)
     //                   all the new elements that were found are passed in as an array
    });   }   ); </script>   </head> <body> <?php $shortname = "neue"; ?>  <?php if(get_option($shortname.'_background_image_url','') != "") { ?> <style type="text/css">   body { background-image: url('<?php echo get_option($shortname.'_background_image_url',''); ?>'); } </style> <?php } ?> <div id="main_container">   <div id="header">       <div class="left">          <?php if(get_option($shortname.'_custom_logo_url','') != "") { ?>
              <a href="<?php bloginfo('url'); ?>"><img src="<?php echo stripslashes(stripslashes(get_option($shortname.'_custom_logo_url',''))); ?>" class="logo" /></a>            <?php } else { ?>
              <a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/logo.jpg" class="logo" /></a>             <?php } ?>                              </div>
                <div class="right">             <div class="head_social">
                <?php if(get_option($shortname.'_twitter_link','') != "") { ?>
                    <a href="<?php echo get_option($shortname.'_twitter_link',''); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/twitter-icon.png" /></a>
                <?php } ?>
                <?php if(get_option($shortname.'_facebook_link','') != "") { ?>
                    <a href="<?php echo get_option($shortname.'_facebook_link',''); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/facebook-icon.png" /></a>
                <?php } ?>
                <?php if(get_option($shortname.'_google_plus_link','') != "") { ?>
                    <a href="<?php echo get_option($shortname.'_google_plus_link',''); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/google-plus-icon.png" /></a>
                <?php } ?>
                <?php if(get_option($shortname.'_dribbble_link','') != "") { ?>
                    <a href="<?php echo get_option($shortname.'_dribbble_link',''); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/dribbble-icon.png" /></a>
                <?php } ?>
                <?php if(get_option($shortname.'_pinterest_link','') != "") { ?>
                    <a href="<?php echo get_option($shortname.'_pinterest_link',''); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/pinterest-icon.png" /></a>
                <?php } ?>
                <div class="clear"></div>           </div><!--//head_social-->
                        <div class="header_menu">   <!--
                <ul>
                    <li><a href="#">HOME</a></li>
                    <li><a href="#">ABOUT</a></li>
                    <li><a href="#">CATEGORIES</a>
                        <ul>
                            <li><a href="#">Wordpress Themes</a></li>
                            <li><a href="#">Create Plugins</a></li>
                            <li><a href="#">Wordpress Themes</a></li>
                            <li><a href="#">Create Plugins</a></li>                         
                        </ul>
                    </li>
                    <li><a href="#">BLOG</a></li>
                    <li><a href="#">CONTACT</a></li>
                </ul>-->
                <?php wp_nav_menu('menu=header_menu&container=false&menu_id='); ?>
                <div class="clear"></div>       </div><!--//header_menu-->
                        <div class="clear"></div> </div>        <div class="clear"></div> <div class="tagline">             <?php echo get_option($shortname.'_header_text','Use Neue Theme Settings to update this text...') ?>        </div><!--//tagline-->
            </div><!--//header-->
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题