Title: Restrict Aside Posts
Last modified: August 18, 2016

---

# Restrict Aside Posts

 *  [techitch](https://wordpress.org/support/users/techitch/)
 * (@techitch)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/restrict-aside-posts/)
 * I used the hack to add asides to my sidebar
    the code I am using is as follows:
 * `
    <?php rewind_posts(); ?> <?php if ($posts) : foreach ($posts as $post) : start_wp();?
   > <?php if (in_category(6)) { ?> <div class="botw"><h5>Band of the Week</h5> 
   <?php echo $post->post_excerpt ?> <?php the_content(); ?> <small><p class="postmetadata"
   ><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?
   > </small> </div> <?php } ?>  <?php if (in_category(7)) { ?> <div class="cotw"
   ><h5>Clown of the Week</h5> <?php echo $post->post_excerpt ?> <?php the_content();?
   > <small><p class="postmetadata"><?php comments_popup_link('No Comments »', '
   1 Comment »', '% Comments »'); ?> </small> </div> <?php } ?>
 * Basically I want to have two categories shown in the sidebar however I only want
   the most recent post from each one to be displayed.. as it is..the sidebar displays
   all of the posts in that category.
 * I tried changing `foreach ($posts as $post)` to a standard for loop which only
   iterates twice however that only gives me the right look if those two aside posts
   are my most recent in the whole site
 * any ideas on how to fix this up??

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

 *  Thread Starter [techitch](https://wordpress.org/support/users/techitch/)
 * (@techitch)
 * [20 years, 2 months ago](https://wordpress.org/support/topic/restrict-aside-posts/#post-374735)
 * bump >:P
 * in essence what i want to do is limit the two aside category posts in my sidebar
   to dislpaying 1 post each
 * have a look [here](http://hyphyhype.com/wp/) if it helps
 *  Thread Starter [techitch](https://wordpress.org/support/users/techitch/)
 * (@techitch)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/restrict-aside-posts/#post-374793)
 * bump >:P
 *  Thread Starter [techitch](https://wordpress.org/support/users/techitch/)
 * (@techitch)
 * [20 years, 1 month ago](https://wordpress.org/support/topic/restrict-aside-posts/#post-374797)
 * ` <?php rewind_posts(); ?>
    <?php $notDone=true?> <?php if ($posts) : foreach(
   $posts as $post) : start_wp(); ?> <?php if (in_category(6) && $notDone) { ?> 
   <div class="botw"><h5>Band of the Week</h5> <?php echo $post->post_excerpt ?>
   <?php the_content(); ?> <small><p class="postmetadata"><?php comments_popup_link('
   No Comments »', '1 Comment »', '% Comments »'); ?> </small> </div> <?php $notDone
   =false ?> <?php } ?> <?php endforeach; else: ?> <p><?php _e('Sorry, no posts 
   matched your criteria.'); ?></p> <?php endif; ?>
 * theres my solution…if anyone cares

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

The topic ‘Restrict Aside Posts’ is closed to new replies.

## Tags

 * [asides](https://wordpress.org/support/topic-tag/asides/)
 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [limit](https://wordpress.org/support/topic-tag/limit/)

 * 3 replies
 * 1 participant
 * Last reply from: [techitch](https://wordpress.org/support/users/techitch/)
 * Last activity: [20 years, 1 month ago](https://wordpress.org/support/topic/restrict-aside-posts/#post-374797)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
