Advertisement
arie_cristianD

show only included 10 popular tags id in tag clouds widgets

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