Advertisement
arie_cristianD

show only included 10 popular tags id in tag clouds widgets

Mar 1st, 2024 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1.  
  2. add_filter( 'widget_tag_cloud_args', 'edit_cloud_tags', 10, 4 );
  3.  
  4. function edit_cloud_tags( $args, $instance ) {
  5.     $popular_tags = get_terms(
  6.         array(
  7.             'taxonomy' => 'post_tag',
  8.             'orderby'  => 'count',
  9.             'order'    => 'DESC',
  10.             'number'   => 10, /* the number of tags list you want to show */
  11.         )
  12.     );
  13.     $tag_list     = array();
  14.     foreach ( $popular_tags as $popular_tag ) {
  15.         $tag_list[] = $popular_tag->term_id;
  16.     }
  17.     $args['include'] = $tag_list; /* show onky the included tags id */
  18.     return $args;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement