Custom sidebar on category page

  • Posted in : Bloggy WP
  • liesjelogthet
    Participant

    Hi I would like to show a custom sidebar on 1 of my category pages. I have added some code to cat.sidebar.php but it doesn’t seem to work yet.
    This is what I have

    I am not a coder so obviously I’ve done something wrong.

    Is it possible to show a custom sidebar on a category page?
    And if so: how do I do that?

    Thanks!

    liesjelogthet
    Participant

    I just noticed: Apparently using code or pre-tags doesn’t work. How can I get the code to display?

    Mehmet S.
    Keymaster

    Hi, use this site to encode your codes:

    http://htmlentities.net

    liesjelogthet
    Participant

    Hi, thanks. This is what I have :

    <?php if (is_category(‘category slug’)) : ?>
    <?php get_sidebar(‘sidebar name’); ?>
    <?php else : ?>
    <?php get_sidebar(); ?>
    <?php endif; ?>

    Mehmet S.
    Keymaster

    You can try this way:

    – create new sidebar from theme options > sidebar

    – go to Appearance > Editor > cat-sidebar.php

    – find:

    get_sidebar();
    

    – edit:

    if ( is_category('category-slug-here') ) { get_sidebar('new-sidebar-name-here'); } else { get_sidebar(); }
    
    liesjelogthet
    Participant

    Hi,

    I tried that edit, but as far as I can tell, the main sidebar is still loading, instead of the custom sidebar I created.

    Any other options?

    This is the exact code I used:

    <?php
    if ( is_category(‘liesjekookthet’) ) { get_sidebar(‘kookbalk1’); } else { get_sidebar(); }
    ?>

    Mehmet S.
    Keymaster

    Created a new php theme file for you.

    – Download sidebar-second.php file at: http://themes.pixelwars.org/bloggy-wp/wp-content/uploads/2014/03/sidebar-second-php-file.zip

    – unzip.

    – copy the sidebar-second.php file to the theme directory.

    – create a new sidebar form theme options > sidebar (Name: second)

    – edit the above line like this:

    if ( is_category('category-slug-here') ) { get_sidebar('second'); } else { get_sidebar(); }
    
    liesjelogthet
    Participant

    That works brilliantly! Thanks a lot!

    Mehmet S.
    Keymaster

    You are welcome.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register