WordPress.org

Ready to get started?Download WordPress

Forums

Add links to edit all pages in Admin Bar (2 posts)

  1. hulku
    Member
    Posted 2 years ago #

    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)

  2. hulku
    Member
    Posted 2 years ago #

    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" => "http://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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags