Title: Loop inside a loop (loopception?) problem :(
Last modified: August 31, 2016

---

# Loop inside a loop (loopception?) problem :(

 *  Resolved [lem0n](https://wordpress.org/support/users/lem0n/)
 * (@lem0n)
 * [10 years ago](https://wordpress.org/support/topic/loop-inside-a-loop-loopception-problem/)
 * Hey guys,
 * I’m new to the whole wordpress thing, and it’s my first time designing a theme
   and I have a problem.
    On a page I need to show post of a specific category and
   an other post from a different category, the first category is used on other 
   pages and that specific page should show the title, the meta and a contact form
   on generated by “contact form 7” which is on a post with it’s own category.
 * I can’t get it to work, I tried a bunch of things, here is the latest:
 *     ```
       <?php
       function tarifs() {
       $temp_query = $wp_query;
       query_posts('category_name=contact-tarif');
       if(have_posts()):
         while(have_posts()):
        		the_post();
   
       		the_content(); 
   
           endwhile;
           endif;
       }
       ?>
       <?php $temp_query = $wp_query; ?>
       <?php query_posts('category_name=techniques'); ?>
       <?php
       //verifier articles ou non ?
   
         if(have_posts()):
       // tend q'on recois des articles
         while(have_posts()):
         	the_post();
   
       			$thumb_id = get_post_thumbnail_id();
       			$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'large', true);
       			$thumb_url = $thumb_url_array[0];
        ?>
       	<section class="parallax-2 module parallax parallax-single parallax-tarifs" style="background-image: url('<?php echo $thumb_url?>')" >
         	<div class="container">
         	<h2 class="tarifs"><?php the_title();?></h2>
         	<div class="left-right">
       		<div class="tarifs-left">
       			<?php
       		    $prix = get_post_meta( get_the_ID(), 'Prix' );
           		echo '<p class="h2 prix">'.$prix[0].'</p><br />';
           		$dure = get_post_meta( get_the_ID(), 'Durée' );
           		echo '<p class="h2 duree">'.$dure[0].'</p>';
           	?>
           	</div>
   
       	  <div class="tarif-right"><?php tarifs(); ?></div>
   
       	</div>
        	</div>
        	</section>
       <?php
           endwhile;
           endif;
       ?>
       ```
   
 * Would really appreciate if you could help me out :/

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

 *  Thread Starter [lem0n](https://wordpress.org/support/users/lem0n/)
 * (@lem0n)
 * [10 years ago](https://wordpress.org/support/topic/loop-inside-a-loop-loopception-problem/#post-7208266)
 * Solved in a way easier and cleaner way -_-
    `<?php echo do_shortcode( '[contact-
   form-7 id="1234" title="Contact form 1"]' ); ?>`
 *  [David Uzelac](https://wordpress.org/support/users/daviduzelac/)
 * (@daviduzelac)
 * [10 years ago](https://wordpress.org/support/topic/loop-inside-a-loop-loopception-problem/#post-7208269)
 * Interesting!
 * Thanks for posting your solution for others encountering the same or similar 
   problems, much appreciated 🙂

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

The topic ‘Loop inside a loop (loopception?) problem :(’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [David Uzelac](https://wordpress.org/support/users/daviduzelac/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/loop-inside-a-loop-loopception-problem/#post-7208269)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
