Advertisement
arnabkumar

How to Show Popular tag in your wordpress

Jun 13th, 2014
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. //Put this code in your theme functions.php
  2.    
  3.     function wpb_tags() {
  4.     $wpbtags =  get_tags();
  5.     foreach ($wpbtags as $tag) {
  6.     $string .= '<span class="tagbox"><a class="taglink" href="'. get_tag_link($tag->term_id) .'">'. $tag->name . '</a><span class="tagcount">'. $tag->count .'</span></span>' . "\n"   ;
  7.     }
  8.     return $string;
  9.     }
  10.     add_shortcode('wptags' , 'wpb_tags' );
  11.    
  12.    
  13.     // How to use - [wptags]
  14.    
  15.     //little bit css to your style.css
  16.    
  17.     .tagbox {
  18.     background-color:#eee;
  19.    border: 1px solid #ccc;
  20.    margin:0px 10px 10px 0px;
  21.     line-height: 200%;
  22.     padding:2px 0 2px 2px;
  23.      
  24.     }
  25.     .taglink  {
  26.     padding:2px;
  27.     }
  28.      
  29.     .tagbox a, .tagbox a:visited, .tagbox a:active {
  30.     text-decoration:none;
  31.     }
  32.      
  33.     .tagcount {
  34.     background-color:green;
  35.     color:white;
  36.     position: relative;
  37.     padding:2px;
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement