Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #103922
    Henriët
    Participant

    Hello team,

    I’ve got another problem with sidebars, unfortunately!

    If I read this correctly, the following code from the sidebars.php:

    		elseif ( is_active_sidebar( 'sidebar-optional-archive' ) && ( is_archive() || ( is_home() && $page_id != $page_for_posts ) ) ) {
    			dynamic_sidebar( 'sidebar-optional-archive' );
        	}

    states that the page_for_posts (or blog page) should display the optional sidebar for archives if it’s active.

    In my case, it is active, and it is displaying correctly as such on the blog-category page (determined by is_archive in the same code lines). However, on the page_for_posts (blog-page), where the most recent posts are shown, there is still the primary sidebar.

    I’m using a static homepage and use a page called “blog” as the page_for_posts (via WordPress dashboard -> settings -> reading). It seems that this page is still considered a “page” after all and thus showing the primary sidebar…

    Can you please help me with this? Thank you very much!

    Kind regards,
    Henriët

    PS: http://test.gewoonmooigewicht.nl; site is still under construction

    #103949
    Pratik
    Keymaster

    Hi @gmg-jet,

    Blog page is considered as page as is_archive() here returns false rather than the latter part. If you want it to be considered as archive for sidebars, you will need to make slight modifications via child theme.

    I checked the site and it looks like you are already using child theme. Just copy the sidebar.php in your child themes’s folder from parent theme and make like 77 of sidebar.php as follows:

    
    elseif ( is_active_sidebar( 'sidebar-optional-archive' ) && is_home() ) {
    

    Let me know how it goes.

    Regards,
    Pratik

    #104007
    Henriët
    Participant

    Hello Pratik!

    Yes, you saw correctly that I’m using a childtheme, it’s so much better than changing core files.
    I really thought that the line as it was called for the “archive sidebar” for the blog page, but you’re absolutely right, of course.
    Followed up on your suggestion and it works perfectly.

    Thank you very much for your quick help! 🙂

    Kind regards,
    Henriët

    #104059
    Pratik
    Keymaster

    Hi @gmg-jet,

    I think I made a small mistake here. Can you add this line instead of the one I gave earlier:

    
    elseif ( is_active_sidebar( 'sidebar-optional-archive' ) && ( is_home() || ( is_archive() || ( is_home() && $page_id != $page_for_posts ) ) ) ) {
    

    In previous one, I missed the condition for archive pages.

    Regards,
    Pratik

    #104076
    Henriët
    Participant

    Hello Pratik,

    Thank you for the correction!
    I see what you did there, and that makes the code complete I think 🙂

    Had noticed that the archive was missing, so I had already altered your first line of code a little bit into:
    elseif ( is_active_sidebar( 'sidebar-optional-archive' ) && ( is_archive() || is_home() ) ) {
    and for some reason that did exactly what your new line does too. Your new line is more complete though, so I have inserted that anyway.

    Kind regards,
    Henriët

    #104080
    Pratik
    Keymaster

    Hi @Henriët,

    I am glad you figured it out even before me 🙂 .

    Regards,
    Pratik

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Posts_page uses primary sidebar, while it should use archive sidebar’ is closed to new replies.