• I’m trying to add a dropdown menu to the Admin Bar with a link to the edit screen for each page on the site, so that I can quickly jump between pages that need editing, without having to go Pages > All Pages > Navigate to the page to edit it.

    I tried writing my function but I just don’t know the code well enough and I can’t put all the parts together.

    I feel like I have to use the add_menu function on the $wp_admin_bar global then somehow get all the page ID’s in an array then build a link to the edit page for each page and a title from the page name, but please let me know f i’m totally off.

    Thanks (in advance)

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

    (@hulku)

    This probably isn’t the most efficient way to do it but I kind of got it working with:

    function customize_menu() {
    global $wp_admin_bar, $post;
    $pages = get_pages(array(“post_type” => “page”, “parent” => 0));

    $wp_admin_bar->add_menu(array(
    “id” => “allpages”,
    “title” => “All Pages”,
    “meta” => array(“target” => ‘blank’)
    ));

    if($pages){
    foreach($pages as $p){
    $wp_admin_bar->add_menu(array(
    “parent” => “allpages”,
    “title” => $p->post_title,
    “href” => “https://localhost:8888/wp-admin/post.php?post=” . $p->ID . “&action=edit”
    ));
    }
    }
    }

    Except now I want a second level dropdown menu, with links to each pages child pages

Viewing 1 replies (of 1 total)
  • The topic ‘Add links to edit all pages in Admin Bar’ is closed to new replies.