• Resolved audriusr

    (@audriusr)


    Hello everyone,

    I want to automatically create wordpress menu once post in custom post type “people” is created. menu name should be the same as slug of the post.

    And ideally menu should be already populated with 5 buttons.

    If you have any ideas on how this function may look, pls feel free to share.

    Thanks in advance.

    [ Please do not bump, that’s not permitted here. ]

Viewing 1 replies (of 1 total)
  • Thread Starter audriusr

    (@audriusr)

    ok, I have figured it out:

    $myPages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'people' AND post_status = 'publish'"); 
    
        foreach ($myPages as $q ){
          $id = 'menu-'.$q->ID;
          $ai_post_title = strtolower($q->post_title);
    	  $ai_slug_as_menu_title = str_replace(" ", "-", $ai_post_title);
          wp_create_nav_menu( $ai_slug_as_menu_title );
        }
Viewing 1 replies (of 1 total)

The topic ‘need help with wp_create_nav_menu() – advanced usage’ is closed to new replies.