2013-12-17 44 views
0

因此,我的侧栏在我的博客页面上工作得很好:beta.cleantelligent.com/blog 但是,当您单击单个帖子时,我希望显示相同的侧栏。single.php上的WordPress侧栏

我假设这将在single.php下,对不对?该代码列在下面。让我知道你是否需要其他代码,我会在这里发布。

我在Wordpress的编辑页面的页面属性中有'博客'边栏,但它只是不被模板识别,我猜?

任何帮助将是伟大的。谢谢!

<?php 
get_header(); ?> 
<div class="blackbar"> 
<div class='bbw'> 
Blog 
</div> 
</div> 
<div class='cont-wrap'> 

<div id="primary"> 
    <?php 
$post_obj = $wp_query->get_queried_object(); 
$post_name = $post_obj->post_name; 
if($post_name == 'blog'){ 
    echo 'Blog'; 
}else{ 
    $parent_title = get_the_title($post->post_parent); 
    echo $parent_title; 
} 
?> 
    <div id="content" role="main"> 

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

      <?php get_template_part('content', 'archive'); ?> 

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

    </div><!-- #content --> 
</div><!-- #primary --> 
<?php get_sidebar(); ?> 
</div> 

的博客页面使用的index.php

<?php 
get_header(); ?> 
<div class="blackbar"> 
<div class='bbw'> 
<?php 
$post_obj = $wp_query->get_queried_object(); 
$post_name = $post_obj->post_name; 
if($post_name == 'blog'){ 
    echo 'Blog'; 
}else{ 
    $parent_title = get_the_title($post->post_parent); 
    echo $parent_title; 
} 
?> 
</div> 
</div> 
<div class='cont-wrap'> 
    <div id="primary"> 
     <div id="content" role="main"> 

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


       <?php get_template_part('content', 'blog'); ?> 



       <?php comments_template('', false); ?> 

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

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

<?php get_sidebar(); ?> 
</div> 

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

这里是我的sidebar.php:

<?php 

$options = twentyeleven_get_theme_options(); 
$current_layout = $options['theme_layout']; 
$nav = sb_get_page_nav($post); 
if ('content' != $current_layout) : 
?> 
<img class="sidebar-top" src='<?php bloginfo('stylesheet_directory'); ?>/images/sidebar-top.png' /> 
    <div id="secondary" class="widget-area" role="complementary"> 
    <?php 
     $post_obj = $wp_query->get_queried_object(); 
     $post_name = $post_obj->post_name; 
     $title = 'cs-' . $post_name; 
     ?> 
    <?php 
     if($post_name == 'news-events'){ 
      if (! dynamic_sidebar('sidebar-web')) : 
      endif; 
     } 
    ?> 

    <?php if(!$nav['no_nav']) { ?> 
     <div class="SimpleSideNav"> 
      <?php wp_nav_menu(array('container_id' => 'left-navigation','menu' => $nav['title'])); ?> 
     </div> 
    <?php } ?> 


    <?php if (! dynamic_sidebar('sidebar-all')) : ?> 
    <?php endif; // end sidebar widget area ?> 
    <?php /* 
    <nav id="left-nav"> 
     <div class="nav-wrapper"> 
      <?php if(!$nav['no_nav']) { 
       wp_nav_menu(array('container_id' => 'left-navigation','menu' => $nav['title'])); 
      } ?> 
     </div> 
    </nav> 
     */ ?> 

     <?php if (! dynamic_sidebar($title)) : ?> 
     <?php endif; // end sidebar widget area ?> 
     <img class="sidebar-bot" src='<?php  bloginfo('stylesheet_directory'); ?>/images/sidebar-bot.png' /> 
    </div><!-- #secondary .widget-area --> 

<?php endif; 
$parent_title = get_the_title($post->post_parent); 
if($parent_title == 'Tour'){ 
echo" 
<script> 
jQuery('.w-1').hide(); 
</script> 
"; 
} 
?> 
+0

哪个模板被博客使用? – Sabari

+0

我把侧边栏放在标题中,它显示在每一页上,但我使用'position:fixed',所以我不知道你是否需要它在定位的位置 –

+0

博客正在使用index.php – JCKnoell

回答

0

我通过创建下侧边栏博客一个全新的侧边栏固定它。 PHP和重定向我的模板。