Guest User

Untitled

a guest
Nov 16th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. function daki_remove_post_top_posts( $posts, $post_ids, $count ) {
  2. foreach ( $posts as $k => $post ) {
  3.  
  4. // Get the list of categories for that post.
  5. $categories = wp_get_post_categories(
  6. $post['post_id'],
  7. // We only need the category slug here.
  8. array( 'orderby' => 'name', 'order' => 'ASC', 'fields' => 'slugs' )
  9. );
  10.  
  11. // Does one of those categories use a category with the "uncategorized" slug?
  12. if ( is_array( $categories ) && ! empty ( $categories ) ) {
  13. foreach ( $categories as $category ) {
  14. if ( 'uncategorized' == $category ) {
  15. unset( $posts[$k] );
  16. }
  17. }
  18. }
  19.  
  20. }
  21.  
  22. return $posts;
  23. }
  24. add_filter( 'jetpack_widget_get_top_posts', 'daki_remove_post_top_posts', 10, 3 );
Add Comment
Please, Sign In to add comment