WordPress.org

Support

Support » How-To and Troubleshooting » How to randomise my menu items.

How to randomise my menu items.

  • So I thought I could do it like this (also I want to only get 3) –

    $menu_items = wp_get_nav_menu_items(26);
    $menu_items = array_rand($menu_items, 3);
    
    foreach ( (array) $menu_items as $key => $menu_item ) {
        $title = $menu_item->title;
        echo $title;
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to randomise my menu items.’ is closed to new replies.
Skip to toolbar