1

I've tried googling this one but I can't seem to find the right keywords.

What I'm trying to do is to have the content of a landing page flow exactly like the hierarchy of the navigation menu.

For example, if I had Home Features Pricing Blog Contact as my menu, I'd like the content block to be in that order (in the same page). If I changed my menu to something like Home Blog Pricing Features Contact, the content block layout should change dynamically in that order as well.

Is there a tutorial/plugin out there (or if someone could explain how it's done) to do this?

Thanks in advance.

2
  • Question: on your landing page, do you want the content to display blocks of content taken from "Home Features etc." or do you want that content to come from somewhere else? – Douglas.Sesar May 5 '14 at 16:16
  • @Douglas.Sesar coming from Home Features etc pages. – Bobby May 6 '14 at 9:13
1

You can use wp_get_nav_menu_items to grab the menu in question,

then go through the array of items to output the content

function output_landing_page_content(){
    //grab the menu items in order
    $menu_items = wp_get_nav_menu_items( $your_menu_id, array( 'orderby' => 'menu_order' ) );

    foreach ( (array) $menu_items as $key => $menu_item ):

        //get post id of linked page/post
        $postid = url_to_postid( $menu_item->url );
        $your_menu_linked_post = get_post( $postid );

        //format content
        $your_content = apply_filters('the_content', $your_menu_linked_post->post_content);

        //display each page/post content however you want (add in titles, author meta or whatever)
        echo $your_content;
        echo '<hr />';

    endforeach;

}

just place your function in the template for your landing page

1
  • I didn't know that function existed, thanks a lot! – Bobby May 8 '14 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.