The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

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

  1. hulku
    Posted 4 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
    Posted 4 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));

    "id" => "allpages",
    "title" => "All Pages",
    "meta" => array("target" => 'blank')

    foreach($pages as $p){
    "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