Display most popular tags of WordPress blog

Below code will return most used tags on the last 30 days from your WordPress blog. Use jQuery and CSS to customize it according to your theme design.

 
<ul id="footer-tags">
    <?php $wpdb->show_errors(); ?> 
    <?php
        global $wpdb;
        $term_ids = $wpdb->get_col("
            SELECT term_id FROM $wpdb->term_taxonomy
            INNER JOIN $wpdb->term_relationships ON $wpdb->term_taxonomy.term_taxonomy_id=$wpdb->term_relationships.term_taxonomy_id
            INNER JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->term_relationships.object_id
            WHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= $wpdb->posts.post_date");
 
if(count($term_ids) > 0){
 
  $tags = get_tags(array(
    'orderby' => 'count',
    'order'   => 'DESC',
    'number'  => 28,
    'include' => $term_ids,
  ));
 
foreach ( (array) $tags as $tag ) {
    echo '<li><a href="' . get_tag_link ($tag->term_id) . '" rel="tag">' . $tag->name . '</a></li>';
}
}
?>
</ul>

Source

Related posts:

HTML5 page structure

HTML5 offers more powerful structure comparing to older versions of Html. There are many new …


Partner with Us

We are providing an exclusive partnership offer to individuals and companies who are interested in setting up their own web design & development company. For more information about how to partner with us, please contact us