_update_post_term_count [ WordPress Function ]
_update_post_term_count ( $terms, $taxonomy )
| Access: |
|
| Parameters: |
|
| Uses: |
|
| Defined at: |
|
Benzer Fonksiyonlar: wp_update_term_count, update_posts_count, _update_generic_term_count, wp_update_term_count_now, update_post_meta
Will update term count based on object types of the current taxonomy.
Private function for the default callback for post_tag and category taxonomies.
Source
<?php
function _update_post_term_count( $terms, $taxonomy ) {
global $wpdb;
$object_types = (array) $taxonomy->object_type;
foreach ( $object_types as &$object_type )
list( $object_type ) = explode( ':', $object_type );
$object_types = array_unique( $object_types );
if ( false !== ( $check_attachments = array_search( 'attachment', $object_types ) ) ) {
unset( $object_types[ $check_attachments ] );
$check_attachments = true;
}
if ( $object_types )
$object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) );
foreach ( (array) $terms as $term ) {
$count = 0;
// Attachments can be 'inherit' status, we need to base count off the parent's status if so
if ( $check_attachments )
$count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) );
if ( $object_types )
$count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );
do_action( 'edit_term_taxonomy', $term, $taxonomy );
$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
do_action( 'edited_term_taxonomy', $term, $taxonomy );
}
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- _update_post_term_count (WordPress Function) - WPSeek.com
WordPress lookup for _update_post_term_count, a WordPress Function. wpseek. com is a WordPress-centric search tool for developers and theme authors.
wpseek.com - Function Reference/register taxonomy « WordPress Codex
Note: If you want to ensure that your custom taxonomy behaves like a tag, you must add the option 'update_count_callback' => '_update_post_term_count'.
codex.wordpress.org - _update_post_term_count
Function and Method Cross Reference. _update_post_term_count(). Defined at: / wp-includes/taxonomy.php -> line 2871. Referenced 1 times: ...
phpxref.ftwr.co.uk - [Solved] Blank Pages with Wordpress 2.6.x | sebthom.de
Sep 13, 2008... 'object_type' => 'post', 'hierarchical' => true, 'update_count_callback' => ' _update_post_term_count'); $wp_taxonomies['post_tag'] = (object) ...
sebthom.de