Site logo

Archived topic

Show Secondary Navigation on posts depending on category

11 replies · Started by dale on June 3, 2017

Viewing posts 1–12 of 12

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?

Hi Dale,

You can try this:

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

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.

Perfect Thanks!

You're welcome :)

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 ...

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?

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!

You're welcome!

This archived topic is closed to new replies.