Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function daki_remove_post_top_posts( $posts, $post_ids, $count ) {
- foreach ( $posts as $k => $post ) {
- // Get the list of categories for that post.
- $categories = wp_get_post_categories(
- $post['post_id'],
- // We only need the category slug here.
- array( 'orderby' => 'name', 'order' => 'ASC', 'fields' => 'slugs' )
- );
- // Does one of those categories use a category with the "uncategorized" slug?
- if ( is_array( $categories ) && ! empty ( $categories ) ) {
- foreach ( $categories as $category ) {
- if ( 'uncategorized' == $category ) {
- unset( $posts[$k] );
- }
- }
- }
- }
- return $posts;
- }
- add_filter( 'jetpack_widget_get_top_posts', 'daki_remove_post_top_posts', 10, 3 );
Add Comment
Please, Sign In to add comment