LATEST >>

Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » WordPress / WordPress Snippets » How To Show List Of Categories By Recently Updated In WordPress?

How To Show List Of Categories By Recently Updated In WordPress?

How-To-Show-List-Of-Categories-By-Recently-Updated-In-WordPressWordPress is an open source CMS so you can do anything with it. In this CMS, there is a category option for post to make your post in right group. Now if you want to show your user that you recently posted in which category then you can do it easily. Its same a latest post widget but its like a latest updated category.

Here you will get your latest category which you used in your post in a list with order like if you want to show latest 10 updated category in lost thn latest updated category will be on top out of ten.

List Of Categories By Recently Updated In WordPress Code:

Now this is a simple PHP code so you have to add it in your theme files not function files. You can add it in sidebar, header, footer, index, pages anywhere easily. Now without any more preface, go to the code and use it in your theme to increase internal linking and catch ore page views.

<?php
    $cat_array = array();
    $args=array(
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 10,
      'caller_get_posts'=> 1
      );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post();
        $cat_args=array('orderby' => 'none');
        $cats = wp_get_post_terms( $post->ID , 'category', $cat_args);
        foreach($cats as $cat) {
          $cat_array[$cat->term_id] = $cat->term_id;
        }
      endwhile;
    }
    if ($cat_array) {
      foreach($cat_array as $cat) {
        $category = get_term_by('ID',$cat, 'category');
        echo '<a href="' . esc_attr(get_term_link($category, 'category')) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>'.'<br />';
      }
    }
    wp_reset_query();
?>

Customization:

You can change 10 with your desired latest updated category to show in list. So if you want to customize it then there is nothing to customize it here. Its ready to used everywhere.

Last Words:

This is what we have and shared in easy steps for newbies so that they can easily know how it works. Stay with us because we are going to share a whole guide step by step about WordPress and make it easy for you. If you liked it then share it and be with us to get next tutorial. If you have any problem then feel free to ask us. We will help you with what we can or have.

You Like It, Please Share This Recipe With Your Friends Using...

6 Responses to “How To Show List Of Categories By Recently Updated In WordPress?”

  1. pari patel says:

    Thanks For Nice Information In Sharing……..

  2. Sonam Gupta says:

    Hello,

    WordPress is an open source CMS so you can do anything with it,I did’t known before your post.

    Thanks for posting this information:)

    Regards:)

    Sonam Gupta

  3. Nice Information about list of categories by recently updated in wordpress , I have to say that for the last few of hours i have been hooked by the impressive articles on this website. Keep up the wonderful work.

Leave a Reply

Your email address will not be published. Required fields are marked *