Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #175364

    1 – Currently the ‘Sidebar Pages’ or ‘Sidebar Blog’ if selected, are displayed in addition to and above the ‘Displayed Everywhere’ sidebar. Is this the correct functioning? I would expect ‘Sidebar Pages’ to override the ‘Displayed Everywhere’ sidebar….? Is this possible?

    2 – I have created a sidebar called ‘Archive Sidebar’ I would like to show this sidebar for category archives rather than the ‘Displayed Everywhere’ sidebar

    Could you please provide code snippet (in I presume sidebar.php) to make this change.
    Thank you for your help!

    #175388

    Hello ttem!

    1. You would need to empty the “Display Everywhere” sidebar in order to hide it from certain pages, because, it displays everywhere.

    2. Yes, the trick is in sidebar.php, open that file an add this code around line 69 (see image):

    if (is_archive()) {
        dynamic_sidebar('Archive Sidebar');
        $default_sidebar = false;
    }

    Best regards,
    Josue

    #175449

    Mil Gracias Josue!

    Ok so to assign a sidebar to a specific category, I would add the category slug in the () like this:

    if (is_archive(restaurants)) {
    dynamic_sidebar(‘Restaurants Sidebar’);
    $default_sidebar = false;
    }

    This should work?

    Will if (is_archive()) also work for custom post type archive?

    #175457

    Hi!

    No, is_archive() does not accept arguments, what you could use is is_category() to filter by a specific category (ex: ‘restaurants’).

    Puedes hablar Español conmigo si prefieres.

    Regards,
    Josue

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

The topic ‘Sidebar functionality and assigning sidebar to category archive page?’ is closed to new replies.