• Hi everyone,

    Thanks for all your help in the past.

    I’m using the right sidebar for most of pages, and I realized that my category pages for my blog posts don’t have a right sidebar. Is there a way to call in the default right sidebar for my category pages? Or set the category pages to a different page template?

    maybe something like this?

    
    if(is_category()){
    dynamic_sidebar( 'right' );
    }
    

    This seems to do nothing, so I could be way off track.

    Thanks for any help! Here’s the page I’d like to add a sidebar to. https://georgedumontier.com/PEC/category/in-the-media/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter georgedumontier

    (@georgedumontier)

    So I made a file called category.php and added it to the child theme.

    I’m working off the custom page example, and this is what I have. I commented out the left sidebar hook and added this after the article closes

       <div class="span4 right tc-sidebar">
                        <div id="right" class="widget-area" role="complementary">
                          <?php dynamic_sidebar( 'right' );?>
                        </div>
                      </div>

    It’s working right now, but I’m not sure this is the best way.

    
    <?php
    /*
    Template Name: Custom Page Example
    */
    ?>
    <?php do_action( '__before_main_wrapper' ); ##hook of the header with get_header ?>
    <div id="main-wrapper" class="<?php echo implode(' ', apply_filters( 'tc_main_wrapper_classes' , array('container') ) ) ?>">
    
        <?php do_action( '__before_main_container' ); ##hook of the featured page (priority 10) and breadcrumb (priority 20)...and whatever you need! ?>
    
        <div class="container" role="main">
          <p>
            testing testing testing testing
          </p>
            <div class="<?php echo implode(' ', apply_filters( 'tc_column_content_wrapper_classes' , array('row' ,'column-content-wrapper') ) ) ?>">
    
                <?php //do_action( '__before_article_container' ); ##hook of left sidebar?>
              
    
                    <div id="content" class="<?php echo implode(' ', apply_filters( 'tc_article_container_class' , array( CZR_utils::czr_fn_get_layout(  CZR_utils::czr_fn_id() , 'class' ) , 'article-container', 'span-8') ) ) ?>">
                      
    
                        <?php do_action( '__before_loop' );##hooks the header of the list of post : archive, search... ?>
    
                            <?php if ( have_posts() ) : ?>
    
                                <?php while ( have_posts() ) : ##all other cases for single and lists: post, custom post type, page, archives, search, 404 ?>
    
                                    <?php the_post(); ?>
    
                                    <?php do_action( '__before_article' ) ?>
                                        <article <?php czr_fn__f( '__article_selectors' ) ?>>
                                            <?php do_action( '__loop' ); ?>
                                        </article>
                                    <?php do_action( '__after_article' ) ?>
    
                                <?php endwhile; ?>
    
                            <?php endif; ##end if have posts ?>
    
                        <?php do_action( '__after_loop' );##hook of the comments and the posts navigation with priorities 10 and 20 ?>
    
                    </div><!--.article-container -->
              <div class="span4 right tc-sidebar">
                        <div id="right" class="widget-area" role="complementary">
                          <?php dynamic_sidebar( 'right' );?>
                        </div>
                      </div>
    
               <?php do_action( '__after_article_container' ); ##hook of left sidebar ?>
    
            </div><!--.row -->
        </div><!-- .container role: main -->
    
        <?php do_action( '__after_main_container' ); ?>
    
    </div><!-- //#main-wrapper -->
    
    <?php do_action( '__after_main_wrapper' );##hook of the footer with get_get_footer ?>
    

    Hi,
    of course, yes. You can use a category template to achieve what you want.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add Sidebar to Category Pages’ is closed to new replies.