Snippets repository for WordPress developpers

Browse
//functions.php
function sp_wp_nav_menu_objects( $items, $args ) {
  // loop
  foreach( $items as &$item ) {
    // vars
    $icon = get_field('call-to-action_option', $item);
    // append icon
    if( $icon ) {
      $item->classes[] = 'cta-btn';
    }
  }
  // return
  return $items;
}
add_filter('wp_nav_menu_objects', 'sp_wp_nav_menu_objects', 10, 2);

Warning: Trying to access array offset on null in /home/clients/7f7a8d8eb6e40c50d3548b06c548734d/web/wp-includes/class-wp-query.php on line 3766

Categories

Tags