WordPress 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.
Table of Contents
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.
Thanks For Nice Information In Sharing……..
Welcome here and thanks for liking our code. Stay with us to get more like this…
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
Welcome here and thanks for liking our article. Stay with us to get more tips like this…
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.
Welcome here and thanks for reading our article and sharing your view.