Can I grab the current taxonomy ID with "If"?

This may be in the documentation somewhere - if so, forgive me.

I created a simple list of taxonomies to generate a navigation menu.

When on the page of the taxonomy item, I want that taxonomy item to display differently (i.e., a different color background.)

Can I grab the current page’s taxonomy ID with If?

Hey Michael, you can definitely do that! You might want to check out this thread for inspiration. That one is a menu loop but the principles should work the same for your taxonomy term loop. One of the things you’ll notice in that thread is that since the information about the current page isn’t available when you’re writing something inside a loop, you’ll need to save a variable outside the loop so that you can pass it to your If tag within your loop.

1 Like
<Loop field=archive_term>
  <Set currentID><Field id /></Set>
</Loop>

<Loop type=taxonomy_term taxonomy=my-tax-slug>
  <If field=id value="{Get currentID}">current term<Else />other term</If>
</Loop>

I think this should do the trick :slight_smile: let me know if it does!

3 Likes

Worked like a charm! :grin: :grin: :grin:

You guys are awesome!

1 Like