Title: Recent Posts
Last modified: August 18, 2016

---

# Recent Posts

 *  Resolved [terrellkl](https://wordpress.org/support/users/terrellkl/)
 * (@terrellkl)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-1-5/)
 * On my blog i have it where it checked to see which category you’re in and lists
   posts from that category under Recent Posts.
 * `<li><h2>
    <?php if ((!is_home()) & (!in_category(8)) & (!in_category(1))) { 
   _e('Recently Answered'); ?></h2>
 * `<ul>
    <?php $categoryvariable=$cat; // assign the variable as current category
   $query= 'showposts=5&cat=' . $categoryvariable. '&orderby=date&order=ASC'; //
   concatenate the query query_posts($query); // run the query ?> <?php if (have_posts()):
   while (have_posts()) : the_post(); ?>
 * `<li><a>"><?php the_title() ?> </a> </li>
    <?php endwhile; endif; ?> </ul> </
   li> <?php } ?>
 * The conditions I’m trying to make are that if you’re not on your home page in
   categories 8 or 1, display Recently Posted Posts From the category you are viewing.
   But when I select a specific post ie. `http:``//**/wordpress/?p=9` it displays
   new posts from every category. It only does this on specific posts pages. How
   can I fix this?
 * PS: How the heck do you use the Markup to format code on this bloody forum?

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

 *  [Chris_K](https://wordpress.org/support/users/handysolo/)
 * (@handysolo)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-1-5/#post-513175)
 * pps: look right BELOW the where you right your post for the section titled “Allowed
   Markup”
 *  [lapoetessa](https://wordpress.org/support/users/lapoetessa/)
 * (@lapoetessa)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-1-5/#post-513182)
 * It’s years since I did any programming, and I am not familiar with whatever language
   you are using here, but even so there must be errors on the syntax of this if
   it does not work. Either that or your LOGIC statement is way off mark.
 *  Thread Starter [terrellkl](https://wordpress.org/support/users/terrellkl/)
 * (@terrellkl)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-1-5/#post-513194)
 * Well I see the problem
    when viewing single posts the variable $cat is not set,
   is there anyway to pull the category from the currently viewed post?
 * Thanks
 *  Thread Starter [terrellkl](https://wordpress.org/support/users/terrellkl/)
 * (@terrellkl)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-1-5/#post-513325)
 * I got it..
    Not much help ya know..
 *  [Chris_K](https://wordpress.org/support/users/handysolo/)
 * (@handysolo)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-1-5/#post-513326)
 * Glad to see you got it working.
 * On average, there are 185+ posts a day here. With a very small number of unpaid
   volunteers to do their best at handling them.
 * Anyone can be a volunteer…. *hint*

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

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

 * 5 replies
 * 3 participants
 * Last reply from: [Chris_K](https://wordpress.org/support/users/handysolo/)
 * Last activity: [19 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-1-5/#post-513326)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
