I am trying to create a menu in wordpress using a custom post type as the main menu item at the top level and all of its childs are going to be included from the posts i create inside it.
The html i would like to try and create is:
<ul>
<li><a href='#'>Home</li>
<li><a href='#'>Products
<ul>
<li class='column'>
<h2>Seating</h2>
<ul>
<li><a href='#'>Custom post link</a></li>
<li><a href='#'>Custom post link</a></li>
<li><a href='#'>Custom post link</a></li>
</ul>
</li>
<li class='column'>
<h2>Desking</h2>
<ul>
<li><a href='#'>Custom post link</a></li>
<li><a href='#'>Custom post link</a></li>
<li><a href='#'>Custom post link</a></li>
</ul>
</li>
<li class='column'>
<h2>Accessories</h2>
<ul>
<li><a href='#'>Custom post link</a></li>
<li><a href='#'>Custom post link</a></li>
<li><a href='#'>Custom post link</a></li>
</ul>
</li>
<li class='column'>
<h2>column4</h2>
<ul>
<li><a href='#'>Custom post link</a></li>
<li><a href='#'>Custom post link</a></li>
<li><a href='#'>Custom post link</a></li>
</ul>
</li>
</ul>
</li>
I have created a custom post type like so:
register_post_type( 'products',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
'show_ui' => true,
'capability_type' => 'post',
'has_archive' => true,
'show_in_nav_menus' => true,
'rewrite' => array('slug' => 'products'),
'supports' => array(
'title',
'editor',
'custom-fields',
'revisions',
'thumbnail',
'page-attributes'
)
)
);
I also have on that custom post a custom meta box to select what category the product is in like so:
function products_category_meta_box_cb($post) {
global $post;
wp_nonce_field('products_category_nonce', 'products_category_meta_box_nonce');
$values = get_post_custom($post->ID);
$menu_value = isset($values['products_category']) ? esc_attr($values['products_category'][0]): '';
$services_array = array('Seating' => 'seating', 'Desking' => 'desking', 'Accessories' => 'accessories');
echo '<p><strong>Select the product category.</strong></p>';
echo '<select name="products-category">';
foreach ($services_array as $key => $value) {
echo '<option value ="' . $value . '"' . selected($menu_value, $value, false) . '>' . $key . '</option>';
}
echo '</select>';
}
what i would like to do is for all of the seating products go inside one li with a class column so i can float them next to each other and the content of that li will be a title which it gets from that dropdown inside the post and then the custom post type links under that.
I hope that makes sense, I know this is quite a complicated question so please ask me if you need some more explanation.
Thanks for reading and would really appreciate your help
Alex