#14669 closed defect (bug) (duplicate)
get_categories returns only after page reload all cats
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | major | Version: | 3.0.1 |
| Component: | Cache API | Keywords: | |
| Focuses: | Cc: |
Description
I am using in a plugin the following script:
// check if default cat exists
if ( !get_cat_ID('ImportFit') )
{
wp_create_category( 'ImportFit' );
}
$categories = get_categories(array('hide_empty' => false));
with a var_dump on $categories I can see, that the created category is returned only after one page reload. in the category view in the backend the created cat is visible.
Change History (6)
#4
follow-up:
↓ 5
@
14 years ago
- Version changed from 3.0.1 to 3.2.1
still with version 3.2.1 I have the same problem. During plugin activation action I have the following code:
// check if default cat exists
if ( !get_cat_ID('Support Tickets') )
{
$cat_id = wp_create_category( 'Support Tickets' );
$cat_id = wp_create_category( 'New Tickets', $cat_id );
}
In the posts->catgories section I get only the "Support Tickets" category, the child category is not listed.
Note: See
TracTickets for help on using
tickets.
This condition is only hit if 2 conditions are met:
This is not unique to Categories, It applies to all terms.
The cause is related to the 'last_changed' cache key used in the Taxonomy API it appears to me.