So basically I have custom post types set up, and one of these is called Packages. It's for a web design/SEO company. I need the nav link Packages to show in the navigation and all of the child links for the link Packages will be all of the posts inside the Packages custom post type. If that's too confusing, just tell me and I can explain more.

What I need to know is how can I make the posts in the Packages custom post type to show as the child pages of the Products page.

Any way this can be done? Preferably with PHP or jQuery.

Edit: This is what I have so far:

    $pages = get_pages('parent=0'); 
    foreach ($pages as $pagg) { $key = 'childpages'; $id = get_the_ID();
        $args = array( 'post_type' => 'products' );
        $loop = new WP_Query( $args );
    if(get_post_meta($id, $key, true) == 'products') :
        $option = '<li><a href="'.get_page_link($page->ID).'">';
        $option .= $pagg->post_title;
        $option .= '</a>';
        $option .= '<ul class="children"';
        while ( $loop->have_posts() ) : $loop->the_post();
            $option .= '<li>';
            $option .= the_title();
            $option .= '</li>';
        $option .= '</ul></li>';
    else : 
        $option = '<li><a href="'.get_page_link($page->ID).'">';
        $option .= $pagg->post_title;
        $option .= '</a></li>';
    echo $option; }

If the page has a custom field of childpages with the value products, display them as the child pages. Will this even work?


Hi @Jared

One idea is to look at the 'rewrite' argument for custom post types.

You can also create a [shortcode] and create a page in your functions.php file for displaying the Packages.

  • This actually lead me to a better solution, I didn't think about using custom menus. Thanks. :)
    – Jared
    Feb 4 '11 at 20:03

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.