Hot answers tagged

1

Bitwise operators expect conditionals on either side of them to evaluate to either TRUE or FALSE. If FALSE it checks the next conditional until it finds a TRUE or all conditionals have been checked. Also, the is_page() function doesn't allow parameters to be passed in on a bitwise basis. So simply change your code to the below and you're good! <?php if ( ...


1

I already had this need, I found this code somewhere in the web. up to you to customize it with your needs. I tested it on the Twenty Nineteen theme: Put this in functions.php : class themeslug_walker_nav_menu extends Walker_Nav_Menu { // add classes to ul sub-menus function start_lvl(&$output, $depth) { // depth dependent classes $indent = (...


1

OK, got it :-) add_filter( 'wp_nav_menu_objects', 'add_nav_menu_item_class' ); function add_nav_menu_item_class( $items ) { foreach ( $items as $item ) { $post_id = get_post_meta( $item->ID, '_menu_item_object_id', true ); $post_tags = get_the_tags( $post_id ); if ( $post_tags ) { foreach( $post_tags as $tag ) { ...


Only top voted, non community-wiki answers of a minimum length are eligible