WordPress.org

Ready to get started?Download WordPress

Forums

How to randomise my menu items. (2 posts)

  1. seanjacob
    Member
    Posted 2 years ago #

    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;
    }
  2. seanjacob
    Member
    Posted 2 years ago #


Topic Closed

This topic has been closed to new replies.

About this Topic