Hook for adding new menu items,showing in wodpress header navbar not in admin menu?

Posted by user1452376 on Stack Overflow See other posts from Stack Overflow or by user1452376
Published on 2013-11-04T09:51:06Z Indexed on 2013/11/04 9:53 UTC
Read the original article Hit count: 314

Filed under:
|
|

I want to add a new menu item by my plugin.I tried a lot but failed. What is the hook for creating a new items in the navbar menu?Please help.

function  add_new_item_in_nav_menu(){

     .....


   }

  action('init','add_new_item_in_nav_menu');

I know how to add the page by a hook

function add_page2(){
    global $user_ID;
    $new_page_title = 'abc';
    $new_page_content = 'abc';
    $new_page_template = ''; 
    $page_check = get_page_by_title($new_page_title);
    $new_page = array(
        'post_type' => 'page',
        'post_title' => $new_page_title,
        'post_content' => $new_page_content,
        'post_status' => 'publish',
        'post_author' => 1,
    );
    if(!isset($page_check->ID)){
        $new_page_id = wp_insert_post($new_page);
        if(!empty($new_page_template)){
            update_post_meta($new_page_id, '_wp_page_template', $new_page_template);
        }
    }

    $homeSet = get_page_by_title( 'Home' );
    update_option( 'page_on_front', $homeSet->ID );
    update_option( 'show_on_front', 'page' );




}
add_action( 'init', 'add_page2' );

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about plugins