Title: Recent Posts Code for Sidebar
Last modified: August 18, 2016

---

# Recent Posts Code for Sidebar

 *  Resolved [heather16](https://wordpress.org/support/users/heather16/)
 * (@heather16)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-code-for-sidebar/)
 * I’d like to include 10 Recent posts and Categories listed on my individual post
   pages. I use the blog.txt theme.
 * Can you please provide the codes that are necessary for WP 2.0?
 * Thanks so much!

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [tsguitar](https://wordpress.org/support/users/tsguitar/)
 * (@tsguitar)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-code-for-sidebar/#post-433182)
 * Recent posts:
    ` <h2>Recent Posts</h2> <ul> <?php get_archives('postbypost', '
   5', 'custom', '<li>', '</li>'); ?> </ul>
 * Change the number 5 to whatever you want.
    Categories: ` <h2>Categories</h2> 
   <ul> <?php wp_list_cats('sort_column=name&optioncount=1'); ?> </ul>
 * Try looking around a bit for the information and you might find it quicker next
   time. Did you do any kind of search for this information first? It’s been covered
   lots of times. Also, this function is built into several templates and the code
   needed to make this happen is readily available. Take a look here for listing
   the recent posts and categories:
    [http://codex.wordpress.org/Template_Tags/get_archives](http://codex.wordpress.org/Template_Tags/get_archives)
   [http://codex.wordpress.org/Template_Tags/wp_list_cats](http://codex.wordpress.org/Template_Tags/wp_list_cats)
 *  Thread Starter [heather16](https://wordpress.org/support/users/heather16/)
 * (@heather16)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-code-for-sidebar/#post-433184)
 * Thanks…I actually did look around but couldn’t find exactly what I needed. Sorry
   for redundance but I appreciate your help (& the other references).
 *  [tsguitar](https://wordpress.org/support/users/tsguitar/)
 * (@tsguitar)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-code-for-sidebar/#post-433185)
 * Can you mark this “Resolved” so others know? Thanks. Glad those are resources
   that you can use.
 *  Thread Starter [heather16](https://wordpress.org/support/users/heather16/)
 * (@heather16)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-code-for-sidebar/#post-433280)
 * When I am trying to copy the codes within my own blog, where does the code begin
   and where does it end? Everytime I try to copy it, I get an error on my blog.
 * I must not be copying the whole code or something. So is there a symbol it starts
   and ends with?
 *  [spencerp](https://wordpress.org/support/users/spencerp/)
 * (@spencerp)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-code-for-sidebar/#post-433285)
 * I know tsguitar added some code there for ya already, for the last 10 posts..
   but, just going to share with ya, this one..right from the Papillon theme:
 * [http://www.vindictivebastard.net/downloads/last-10-posts.txt](http://www.vindictivebastard.net/downloads/last-10-posts.txt)
 * spencerp
 *  [tsguitar](https://wordpress.org/support/users/tsguitar/)
 * (@tsguitar)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-code-for-sidebar/#post-433303)
 * Make sure you aren’t pasting the code I gave you in between any PHP tags or you’ll
   get an error. For instance, try pasting that code at the very beginning of your
   sidebar, right after the initial DIVs, before anything else.
 * You copy from the `<h2>` to the `</ul>`. There’s nothing missing. If there’s 
   an error on your site, then you have other problems with your templates or you’re
   pasting it in the wrong spot. If you glance at the default WordPress template(
   which you have installed on your blog, even if you aren’t using it), you’ll see
   that code there, too.
 * Both the code I sent and the code spencerp suggests are clean and should work
   just fine.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Recent Posts Code for Sidebar’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [tsguitar](https://wordpress.org/support/users/tsguitar/)
 * Last activity: [19 years, 8 months ago](https://wordpress.org/support/topic/recent-posts-code-for-sidebar/#post-433303)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
