Opened 8 years ago
Closed 8 years ago
#42765 closed enhancement (invalid)
Add the filter to the taxonomy metabox when editing a post
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.9.1 |
| Component: | Taxonomy | Keywords: | needs-patch good-first-bug close |
| Focuses: | administration | Cc: |
Description
The filter (default_term_id) is needed to set a default term in the custom taxonomy for custom post type.
File: /wp-admin/includes/meta-boxes.php, Line: 542
<div id="<?php echo $tax_name; ?>-all" class="tabs-panel">
<?php
$name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']';
echo "<input type='hidden' name='{$name}[]' value=' . apply_filters( 'default_term_id', 0, tax_name ) . ' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
?>
<ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear">
<?php wp_terms_checklist( $post->ID, array( 'taxonomy' => $tax_name, 'popular_cats' => $popular_ids ) ); ?>
</ul>
</div>
Change History (8)
#4
@
8 years ago
@mihdan proposal sounds very reasonable. After all, posts are not limited to categories.
#5
@
8 years ago
- Keywords needs-patch good-first-bug added
- Milestone changed from Awaiting Review to Future Release
#6
@
8 years ago
Michael, thank you for your ticket.
It seems that wp_terms_checklist_args is the filter you are looking for. It can be used to override the selected_cats argument. If it's empty set the default as needed.
Note: See
TracTickets for help on using
tickets.
Yes, make it happen please!