Don't query post cats if no post. see #2621

git-svn-id: http://svn.automattic.com/wordpress/trunk@7739 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-04-18 18:12:04 +00:00
parent 3495bf80e0
commit 65e4ddc684
2 changed files with 7 additions and 3 deletions

View File

@ -241,7 +241,7 @@ endif; ?>
<div id="categories-all" class="ui-tabs-panel"> <div id="categories-all" class="ui-tabs-panel">
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
<?php wp_category_checklist($post->ID) ?> <?php wp_category_checklist($post_ID) ?>
</ul> </ul>
</div> </div>

View File

@ -156,11 +156,15 @@ class Walker_Category_Checklist extends Walker {
} }
} }
function wp_category_checklist( $post_id ) { function wp_category_checklist( $post_id = 0 ) {
$walker = new Walker_Category_Checklist; $walker = new Walker_Category_Checklist;
$args = array(); $args = array();
if ( $post_id )
$args['selected_cats'] = wp_get_post_categories($post_id); $args['selected_cats'] = wp_get_post_categories($post_id);
else
$args['selected_cats'] = array();
$args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10 ) ); $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10 ) );
$categories = get_categories('get=all'); $categories = get_categories('get=all');
$args = array($categories, 0, $args); $args = array($categories, 0, $args);