Two useful features, customizable at will, to be used to show the last n posts of a category or one or more tags. Functions, as you will see, are very similar and are both based on a loop generated by query_post() . The first, show_title_cat() , shows the last post (in this version only the title) of a specific category:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | / ** * Show the last posts of a certain category * * @ Return * @ Param object $ cats * @ Param object $ show [optional] * / show_title_cat function ($ cats, $ show = 5) { global $ post; $ Posts = query_posts ('cat ='. $ Cats. 'Showposts & ='. $ Show); echo "<ul>"; foreach ($ posts as $ post): setup_postdata ($ post);?> ; ?> " rel="bookmark"> <?php the_title ( ) ; ?> </a></li> <li> <a href = "<? php the_permalink ();?>" rel = "bookmark"> <? php the_title ();?> </ a> </ li> ; <? Php endforeach; ; echo "</ ul>"; } |
For example:
1 | '748' ) ; ?> <? Php show_title_cat ('748 ');?> |
The second function, perhaps more interestingly, shows the last post filtering by tag:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | / ** * Show the last posts with a particular tag * * @ Return * @ Param object $ tag * @ Param object $ show [optional] * / show_title_tag function ($ tag, $ show = 5) { global $ post; $ Posts = query_posts ('tag ='. $ Tag. 'Showposts & ='. $ Show); echo "<ul>"; foreach ($ posts as $ post): setup_postdata ($ post);?> ; ?> " rel="bookmark"> <?php the_title ( ) ; ?> </a></li> <li> <a href = "<? php the_permalink ();?>" rel = "bookmark"> <? php the_title ();?> </ a> </ li> ; <? Php endforeach; ; echo "</ ul>"; } |
For example:
1 | 'photoshop,tutorials' ) ; ?> <? Php show_title_tag ('photoshop tutorials');?> |










[...] WordPress allows you to get a list of post setting several search parameters (see Very short snippet: Display a list of posts by category or tags). Precisely because of its versatility in the search of the posts may be that using the [...]
[...] [...]