wp_popular_terms_checklist [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Retrieve a list of the most popular terms from the specified taxonomy.
If the $echo argument is true then the elements for a list of checkbox elements labelled with the names of the selected terms is output. If the $post_ID global isn't empty then the terms associated with that post will be marked as checked.
Source
<?php
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
global $post_ID;
if ( $post_ID )
$checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids'));
else
$checked_terms = array();
$terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
$tax = get_taxonomy($taxonomy);
if ( ! current_user_can($tax->cap->assign_terms) )
$disabled = 'disabled="disabled"';
else
$disabled = '';
$popular_ids = array();
foreach ( (array) $terms as $term ) {
$popular_ids[] = $term->term_id;
if ( !$echo ) // hack for AJAX use
continue;
$id = "popular-$taxonomy-$term->term_id";
$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
?>
<li id="<?php echo $id; ?>" class="popular-category">
<label class="selectit">
<input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php echo $disabled ?>/>
<?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?>
</label>
</li>
<?php
}
return $popular_ids;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- wp_popular_terms_checklist() WordPress function reference ...
wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ). taxonomy: (unknown_type); default: (unknown_type) Default: 0; number ...
queryposts.com - Wordpress - Category list order in post edit page - Stack Overflow
checklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?> </ul> </div> <div ...
stackoverflow.com - How to change default parameter value of a Wordpress core ...
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ echo = true ). it's defined in wp-admin/wp-includes/template.
stackoverflow.com - Docs for page template.php
unknown wp_popular_terms_checklist (unknown_type $taxonomy, [ unknown_type $default = 0], [unknown_type $number = 10], [unknown_type $ echo = true]) ...
phpdoc.ftwr.co.uk