• So for my website, I am making it so that the content of each page in the current navigation menu would be displayed on the main home page.

    So main question is, how would I write the query so that it looks up all the pages which are in the navigation menu?

    Would I need to find out the page_id of each page in the menu and then pass that information through query? If so, how would I find the page_id of the nav_menu?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    The nav menu only stores the actual URL, no other pertinent information. After all, a menu link could even be offsite if you were so inclined. So there is not one single way to get more information about a menu item, it depends on the nature of the URL.

    If all the links are page slugs, you could pull the URLs out of the DB and extract the slug. Then use the slug to retrieve the page. Perhaps easier is to setup your home page template with a series of iframes for which the menu URL is inserted directly into the iframe src attribute.

    To get all the menu URLs, query for all the menu items, which are special post type ‘nav_menu_item’. The URLs are in postmeta for each menu item under the key ‘_menu_item_url’.

    Thread Starter hyoon01

    (@hyoon01)

    k thanks a lot!!

    It may help

    query_posts(array('showposts' => <number_of_pages_to_show>, 'post_parent' => <ID of the parent page>, 'post_type' => 'page'));
    
    while (have_posts()) { the_post();
        /* Do whatever you want to do for every page... */
    }
    
    wp_reset_query();  // Restore global post data
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to loop through PAGES in custom Navigation Menu’ is closed to new replies.