Show recent posts for specific category
Many blogger today are inclined to use WordPress, as well for them, here I I have a good trick with which you can display the most recent post for a specific category.
As you know to show recent WordPress post using this:
\u0026lt;h2> Recent Posts \u0026lt;/ h2>
\u0026lt;ul>
\u0026lt;? Php get_archives ('postbypost', 6);?>
\u0026lt;/ ul>
But how can we show the specific post for a particular category?, Just what we need to sustitur Previous by the following:
\u0026lt;ul>
\u0026lt;? php $ Recent = new WP_Query ("cat = 1 & showposts = 10") while ($ recent-> have_posts ()): $ recent- > the_post ();?>
\u0026lt;li> \u0026lt;a href = "\u0026lt;? php the_permalink ()?>" rel = "bookmark">
\u0026lt;? Php the_title ();?>
\u0026lt;/ a> \u0026lt;/ li>
\u0026lt;? Php endwhile;?>
\u0026lt;/ ul>
cat = 1 Here is our category ID number and showposts = 10 are our recent spost counter specific category.
Ok, when you add this code to your sidebar.php file, you must check the specific ID for the category, this can be done from the admin panel, manage, categories.
0 comments:
Post a Comment