[wp-trac] [WordPress Trac] #14788: get_categories returns (sub)categories with drafts
WordPress Trac
wp-trac at lists.automattic.com
Mon Sep 6 09:01:09 UTC 2010
#14788: get_categories returns (sub)categories with drafts
--------------------------+-------------------------------------------------
Reporter: illutic | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.0.1
Severity: major | Keywords: get_categories
--------------------------+-------------------------------------------------
As stated in [http://wordpress.org/support/topic/get_categories-includes-
categories-with-drafts this topic], categories with drafts only are also
included in the get_categories list.
The code I'm using (to get subcategories, it's inside functions.php):
{{{
/* subcategories */
$args = array(
'type' => 'post',
'child_of' => $id
);
foreach (get_categories($args) as $cat)
{
echo '<p><span class="subcategory">';
$apps = $cat->category_count == 1 ? 'apartment' : 'apartments';
echo '<a href="'.get_category_link( $cat->cat_ID
).'">'.$cat->cat_name.'</a> <small> ('.$cat->category_count.' ' . $apps .
')</small>';
if ($cat->category_description != '')
{
echo '<br />'.$cat->category_description . ' <a
href="'.get_category_link( $cat->cat_ID ).'">View the apartments
»</a>';
}
echo '</span></p>';
} // end foreach
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14788>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list