I have a custom content type "balloons", and I've assigned a parent category to a "balloon" item, "Water Balloon"

I've made the Balloon category a primary menu item. I want a link to "Water Balloon" to show in the dropdown, as it would if it was a page.

I don't know how to do this, or if it's possible. Any ideas? Thanks in advance.

  • So far I've found that I can use the menu to controls to add the new content item to the menu, and indent so it appears in the dropdwon,. This will do the trick for now, but I could end up with hundreds of these, and need the system to be easily usable by others, so it's not the right solution. – puppybeard Jun 10 '11 at 11:15
  • Basically you want to add a "custom post type's Taxonomy (Category)" to your Navigation (accessible via Appearance > Menus) right? – Xavier Jun 10 '11 at 12:21
  • Yes, that sums it up. – puppybeard Jun 10 '11 at 12:27
  • To clarify, I can add the category to the menu, and I can assign the category to my custom content, but it doesn't display as a secondary menu item, the way a page does. – puppybeard Jun 10 '11 at 13:17
  • So in other words, you want to list all balloon categories under "Baloons" in your menu? – TheDeadMedic Jun 30 '11 at 10:19

If i understand the question correct then you need this:

function auto_category_subMenu($item_output, $item, $depth, $args){
    //first you check if the current item is a category
    if (!$item->object == 'category'){
        return $item_output;
    //if it is a category then check that it is the right one.
        if ($item->title == 'Water Balloon'){
               //if we got this far the we are on the parent menu item and
               // we are going to get all of the balloon post type listed under it
            global $post;
            $tmp_post = $post;
            $args = array(
                'post_type' => 'balloons',
                'posts_per_page' => -1,
                'category_name' => $item->title
            $re = '';
            $submenu_items = get_posts( $args );
            foreach( $submenu_items as $post ){
                $re .= '<li ><a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a></li>';
            $post = $tmp_post;
            return $item_output.'<ul>'.$re.'</ul>';
    return $item_output;

this code assumes that your category name is "Water Balloon" and your post type is named "balloons" if not simply change that.

|improve this answer|||||
  • Um need some limit here.. if you have 30 items on a list it can easily be a user experience issue here. Rather then all the items I rather see 5 most popular items. How that get implemented is another issue (can be done via menu editor). – Azizur Rahman Jun 30 '11 at 14:48
  • Limit is easy here just change posts_per_page to 5 or anything else you'd like, as for most popular items that is another issue. – Bainternet Jun 30 '11 at 15:51

It's very likely you have some kind of collusion somewhere. Is it possible you have something like?

register_post_type( 'balloon', $args ); and also register_taxonomy( 'balloon', array('balloon'), $args );

Take a look at the code below. It's a complete plugin. Compare this with your code.

  @Plugin Name: Balloons - Balloons Directory
  @Plugin URI: http://azizur-rahman.co.uk/
  @Description: Balloons Directory Manager
  @Author: Azizur Rahman
  @Version: 1.0
  @Author URI: http://azizur-rahman.co.uk/
  @package balloons

add_action( 'init', 'azizur_register_cpt_balloons' );

function azizur_register_cpt_balloons() {

    $labels = array( 
        'name' => _x( 'balloons', 'balloons' ),
        'singular_name' => _x( 'balloon', 'balloons' ),
        'add_new' => _x( 'Add New', 'balloons' ),
        'add_new_item' => _x( 'Add New balloon', 'balloons' ),
        'edit_item' => _x( 'Edit balloon', 'balloons' ),
        'new_item' => _x( 'New balloon', 'balloons' ),
        'view_item' => _x( 'View balloon', 'balloons' ),
        'search_items' => _x( 'Search balloons', 'balloons' ),
        'not_found' => _x( 'No balloons found', 'balloons' ),
        'not_found_in_trash' => _x( 'No balloons found in Trash', 'balloons' ),
        'parent_item_colon' => _x( 'Parent balloon:', 'balloons' ),
        'menu_name' => _x( 'balloons', 'balloons' ),

    $args = array( 
        'labels' => $labels,
        'hierarchical' => false,
        'description' => 'balloons content type',
        'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
//        'taxonomies' => array( 'page-category', 'balloon-category' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,

        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post'

    register_post_type( 'balloons', $args );

add_action( 'init', 'azizur_register_taxonomy_balloon_types' );

function azizur_register_taxonomy_balloon_types() {

    $labels = array( 
        'name' => _x( 'Balloon Types', 'balloon types' ),
        'singular_name' => _x( 'Balloon Type', 'balloon types' ),
        'search_items' => _x( 'Search Balloon Type', 'balloon types' ),
        'popular_items' => _x( 'Popular Balloon Type', 'balloon types' ),
        'all_items' => _x( 'All Balloon Type', 'balloon types' ),
        'parent_item' => _x( 'Parent Balloon Types', 'balloon types' ),
        'parent_item_colon' => _x( 'Parent Balloon Types:', 'balloon types' ),
        'edit_item' => _x( 'Edit Balloon Types', 'balloon types' ),
        'update_item' => _x( 'Update Balloon Types', 'balloon types' ),
        'add_new_item' => _x( 'Add New Balloon Types', 'balloon types' ),
        'new_item_name' => _x( 'New Balloon Types Name', 'balloon types' ),
        'separate_items_with_commas' => _x( 'Separate balloon type with commas', 'balloon types' ),
        'add_or_remove_items' => _x( 'Add or remove balloon type', 'balloon types' ),
        'choose_from_most_used' => _x( 'Choose from the most used balloon type', 'balloon types' ),
        'menu_name' => _x( 'Balloon Types', 'balloon types' ),

    $args = array( 
        'labels' => $labels,
        'public' => true,
        'show_in_nav_menus' => true,
        'show_ui' => true,
        'show_tagcloud' => true,
        'hierarchical' => true,

        'rewrite' => true,
        'query_var' => true

    register_taxonomy( 'balloon_types', array('balloons'), $args );

function azizur_balloons_cpt_rewrite_flush() {
register_activation_hook(__FILE__, 'azizur_balloons_cpt_rewrite_flush');
register_deactivation_hook(__FILE__, 'azizur_balloons_cpt_rewrite_flush');

|improve this answer|||||
  • This looks very promising. Unfortunately I won't get a chance to ry it until maybe next week, but I'll let you know how I get on. How would editing this in the admin section be handled? Does it support multiple textareas? – puppybeard Jun 29 '11 at 9:07
  • As is it has 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats'.But you can extend this to add editional text areas. – Azizur Rahman Jun 29 '11 at 10:06
  • But this doesn't answer the question at all! – TheDeadMedic Jun 30 '11 at 10:17
  • @thedeadmedic I may have misunderstood the question. – Azizur Rahman Jun 30 '11 at 14:44

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.