2013-12-17 49 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和重定向我的模板。