[Resolved] Show Secondary Navigation on posts depending on category

Home Forums Support [Resolved] Show Secondary Navigation on posts depending on category

Home Forums Support Show Secondary Navigation on posts depending on category

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #328077
    dale

    I found the earlier discussions where you showed how to display secondary navigation only on specified pages with this css:

    .secondary-navigation {
          display: none;
    }
    
    .page-id-xx .secondary-navigation {
          display: block;
    }

    If I also want to show the secondary nav menu on posts with a certain category, would I need to use a PHP filter then?

    #328103
    Leo
    Staff
    Customer Support

    Hi Dale,

    You can try this:

    .secondary-navigation {
          display: none;
    }
    .category-xx .secondary-navigation,
    .single .secondary-navigation {
          display: block;
    }
    #328139
    dale

    Thanks! That’s what I’m using to have it appear on the category archive page, but it doesn’t seem to work for the individual posts.

    I purged caches and Cloudflare.

    #328141
    Leo
    Staff
    Customer Support
    #328160
    dale

    Perfect Thanks!

    #328162
    Leo
    Staff
    Customer Support

    You’re welcome ๐Ÿ™‚

    #328172
    dale

    I spoke to soon. I realized later that code made the secondary nav appear on all my single posts. I tried revising it as

    .category-chechnya  .secondary-navigation,
    .category-chechnya .single .secondary-navigation {
          display: block;
    }

    But that removed it from all single posts pages for some reason …

    #328179
    Leo
    Staff
    Customer Support

    Can you try this?

    .category-chechnya  .secondary-navigation,
    .category-chechnya.single .secondary-navigation {
          display: block;
    }

    Link me to the page if it doesn’t work?

    #328186
    dale

    That didn’t work either. Could the PHP that puts the featured image/header directly below the navigation on these category pages be interfering?

    Here’s an example:

    https://dalecameronlowry.com/chechnya-gay-purge-26-dead-many-imprisoned/

    If it’s too difficult to solve, no worries. This is a would-be-nice-to-have, not a must-have.

    #328188
    Leo
    Staff
    Customer Support
    #328210
    dale

    Okay. I added that PHP from the link and with this CSS,

    .category-chechnya  .secondary-navigation,
    .category-chechnya .single .secondary-navigation {
          display: block;
    }

    I got the result I was looking for.

    .category-chechnya  .secondary-navigation,
    .single .secondary-navigation {
          display: block;
    }

    resulted in all posts getting secondary nav, and

    .category-chechnya  .secondary-navigation,
    .category-chechnya.single .secondary-navigation {
          display: block;
    }

    resulted in none getting it. just FYI.

    And now with this PHP I’ll be able to go hogwild with my category formatting ๐Ÿ™‚ Thank you!

    #328220
    Leo
    Staff
    Customer Support

    You’re welcome!

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.