Friday, December 23, 2022
HomeWordPress Developmentcustomized subject - Add CSS class to posts with sure meta key

customized subject – Add CSS class to posts with sure meta key


I’m engaged on my header navigation and I need to underline the menu merchandise for sure circumstances.

I want to add a CSS class if

  • the put up has the ID 21638, or
  • the put up has the meta worth ‘bloom’

The meta worth is an ACF relationship subject.

<nav class="header-navigation">
<ul class="header-navigation__list">
    <li <?php if (is_single(21638)) or (metadata_exists('bloom') echo 'class="current-menu-item"' ?>><a href="<?php echo site_url('/labels/bloom') ?>">Bloom</a></li>
</ul>

I managed to resolve the put up ID half, however how do I add situation relating to meta worth?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments