12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Nov 23, 2022

Checking if the current category archive page is either the specified category or a child of the specified category

Sridhar Katakam

In WPDevDesign Facebook group a user asks:

Oxygen Condition needed

I have default WP posts categories like below :

HOME DECOR TIPS
- INDOOR TIPS

- - DINING ROOM TIPS

- - BEDROOM TIPS

- - STUDY ROOM TIPS

- GARDEN TIPS
- - PLANTERS TIPS

- - WALL HANGERS TIPS

OUTDOOR TIPS

- LIGHTING AREA
- - SECURITY TIPS

I want to make a template with different header for parent categories only. LIKE "Header 1" on HOME DECOR TIPS and "Header 2" on OUTDOOR TIPS and these headers will follow child and grandchild categories as well.

This members-only tutorial shows how this can be done by defining a custom function that returns true or false depending on whether the current category archive page being viewed is either the specified category or one of its child categories and using it with Oxygen's Dynamic Data condition.

Step 1

Add the following in a custom functionality plugin or a code snippets plugin:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $599 one-time).

Already a member? Log in below or here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right