WordPress

メニューの項目数を取得

'20.08.30
<?php
  $args = [
    'meta_query'    => [
      [
        'key'       => '_menu_item_menu_item_parent',
        'value'     => 0,
        'compare'   => '=',
      ]
    ]
  ];
  $count = count( wp_get_nav_menu_items( 'メニューの名前', $args ) );
?>

 

(View60)