• I’ve got multiple menus that I want to display only on certain archive pages. In one situation, I want the menu to display ONLY if the posts are in 2 different categories.

    So I guess the code could look something like the following…

    <?php if (in_category('acoustic') || in_category('artists')) { ?>

    This doesn’t work but I wondered if its possible?

    So if a post is in ‘artists’ AND ‘acoustic’ then display menu…
    If it’s only in one of those then don’t display menu…

    Any thoughts appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The line of code you specified is a logical OR. To make it an AND you need to change it to:

    <?php if (in_category('acoustic') && in_category('artists')) { ?>

    Try it and see if it makes a difference.

    Thread Starter dmx09

    (@dmx09)

    Great, many thanks – I’ll give it a go!

    Thread Starter dmx09

    (@dmx09)

    Thanksd for that – I havent been able to test it yet but from what I’ve seen on the codex it should work.

    Is there a way to add a similar ‘AND’ to an a href link? For example I have a bunch of links on a page which I’d like to load multiple categories and not sure what the best method to achieve this.

    This is what I’ve currently got:

    <a href="/?cat=33">Acoustic</a>
    <a href="/?cat=12">Funk</a>

    Is something like this possible?

    <a href="/?cat=9&&cat16">Funk</a>
    <a href="/?cat=12&&cat17">Funk</a>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display item if in Category A 'AND' Category B’ is closed to new replies.