WPSEO_Post_Type_Sitemap_Provider::get_post_type_count()
Get count of posts for post type.
Метод класса: WPSEO_Post_Type_Sitemap_Provider{}
Хуки из метода
Возвращает
int
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_post_type_count( $post_type );
- $post_type(строка) (обязательный)
- Post type to retrieve count for.
Код WPSEO_Post_Type_Sitemap_Provider::get_post_type_count() WPSEO Post Type Sitemap Provider::get post type count Yoast 22.3
protected function get_post_type_count( $post_type ) { global $wpdb; /** * Filter JOIN query part for type count of post type. * * @param string $join SQL part, defaults to empty string. * @param string $post_type Post type name. */ $join_filter = apply_filters( 'wpseo_typecount_join', '', $post_type ); /** * Filter WHERE query part for type count of post type. * * @param string $where SQL part, defaults to empty string. * @param string $post_type Post type name. */ $where_filter = apply_filters( 'wpseo_typecount_where', '', $post_type ); $where = $this->get_sql_where_clause( $post_type ); $sql = " SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} {$join_filter} {$where} {$where_filter} "; return (int) $wpdb->get_var( $sql ); }