Title: Loop modification
Last modified: August 20, 2016

---

# Loop modification

 *  [gouldimal](https://wordpress.org/support/users/gouldimal/)
 * (@gouldimal)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/loop-modification/)
 * Hello,
 * I am trying to show posts with the tag “medical” if they are a child of page 
   843, and so far, I have everything mostly working. I need to get some HTML within
   this if statement so that I can enclose it all in a div, and also to set an opening
   and closing
    -  for the list. Can someone please help me get over this last hump?
 *     ```
       <?php
       if (843 == $post->post_parent) {
       global $post;
       $myposts = get_posts('numberposts=10&tag=medical&order=DESC');
       foreach($myposts as $post) :
       ?>
       <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
       <?php endforeach;
       }
       ?>
       ```
   

The topic ‘Loop modification’ is closed to new replies.

## Tags

 * [if](https://wordpress.org/support/topic-tag/if/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [gouldimal](https://wordpress.org/support/users/gouldimal/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/loop-modification/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
