Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

For some time I've been using this code snippet adding both custom post types and custom taxonomies to the WP Dashboard Right Now widget:

function dashboard_right_now_content_table_end() {
    $args = array(
        'public' => true,
        '_builtin' => false
    );
    $output = 'object';
    $operator = 'and';
    $post_types = get_post_types($args, $output, $operator);
    foreach ($post_types as $post_type) {
        $num_posts = wp_count_posts($post_type->name);
        $num = number_format_i18n($num_posts->publish);
        $text = _n($post_type->labels->singular_name, $post_type->labels->name, intval($num_posts->publish));
        if (current_user_can('edit_posts')) {
            $num = "<a href='edit.php?post_type=$post_type->name'>$num</a>";
            $text = "<a href='edit.php?post_type=$post_type->name'>$text</a>";
        }
        echo '<tr><td class="first b b-' . $post_type->name . '">' . $num . '</td>';
        echo '<td class="t ' . $post_type->name . '">' . $text . '</td></tr>';
    }
    $taxonomies = get_taxonomies($args, $output, $operator);
    foreach ($taxonomies as $taxonomy) {
        $num_terms = wp_count_terms($taxonomy->name);
        $num = number_format_i18n($num_terms);
        $text = _n($taxonomy->labels->singular_name, $taxonomy->labels->name, intval($num_terms));
        if (current_user_can('manage_categories')) {
            $num = "<a href='edit-tags.php?taxonomy=$taxonomy->name'>$num</a>";
            $text = "<a href='edit-tags.php?taxonomy=$taxonomy->name'>$text</a>";
        }
        echo '<tr><td class="first b b-' . $taxonomy->name . '">' . $num . '</td>';
        echo '<td class="t ' . $taxonomy->name . '">' . $text . '</td></tr>';
    }
}
add_action('right_now_content_table_end', 'dashboard_right_now_content_table_end');

Using this taxonomy:

function create_secondary_taxonomies() {
    $labels = array(
        'name' => _x('Mogelijkheden', 'taxonomy general name'),
        'singular_name' => _x('Mogelijkheid', 'taxonomy singular name'),
        'search_items' => __('Search Categories'),
        'all_items' => __('All Categories'),
        'parent_item' => __('Parent Category'),
        'parent_item_colon' => __('Parent Category:'),
        'edit_item' => __('Edit Category'),
        'view_item' => __('View Category'),
        'update_item' => __('Update Category'),
        'add_new_item' => __('Add New Category'),
        'new_item_name' => __('New Category Name'),
        'menu_name' => __('Mogelijkheden')
    );
    register_taxonomy('mogelijkheden', array(
        'portfolio'
    ), array(
        'labels' => $labels,
        'hierarchical' => true,
        'query_var' => true,
        'rewrite' => array(
            'hierarchical' => true,
            'slug' => 'mogelijkheden',
            'with_front' => false
        ),
        'public' => true,
        'show_ui' => true,
        '_builtin' => true
    ));
}
add_action('init', 'create_secondary_taxonomies');

This all worked great. Until recently. Currently it is still showing the custom post types, but it isn't showing the custom taxonomies anymore.

Does someone notices any errors or things that could conflict with this code perhaps?

share|improve this question
    
Thanks @t31os! It completely solved the issue. –  Cor van Noorloos Dec 4 '11 at 21:26
    
Moved the fix into an answer so you can mark it correct later.. ;) Happy to have helped. –  t31os Dec 4 '11 at 21:29
    
@t31os, I was about to ask (: Thanks again. –  Cor van Noorloos Dec 4 '11 at 21:52

1 Answer 1

up vote 0 down vote accepted

Moved from comment to answer:

Inside your taxonomy registration code, '_builtin' => true shouldn't be set to true, that's specifically for built in taxonomies only(you shouldn't even be setting that arg) and also conflicts with your args array which specifically asks for a false value.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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