Title: custom loop question
Last modified: August 20, 2016

---

# custom loop question

 *  [wplearner](https://wordpress.org/support/users/wordpresslearner/)
 * (@wordpresslearner)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/custom-loop-question-1/)
 * Hey so I’m trying to learn the basics of custom loops, so I set up a single.php
   template in a childtheme of the sandbox theme, and I put the following code in
   it:
 * _[please follow the [forum guidelines for posting and marking code](http://codex.wordpress.org/Forum_Welcome#Posting_Code)]_
 * <?php get_header() ?>
 *  <div id=”container”>
    <div id=”content”> <?php $myPosts = new WP_Query(); $myPosts-
   >query(’posts_per_page=1’); while($myPosts->have_posts()) : $myPosts->the_post();?
   ><?php the_content();?> <?php endwhile; ?> <?php comments_template() ?>
 *  </div><!– #content –>
    </div><!– #container –>
 * <?php get_sidebar() ?>
    <?php get_footer() ?>
 * But whenever I run this on a single post I get an error saying:
 * Parse error: syntax error, unexpected ‘=’ in /home/a9394669/public_html/wp-content/
   themes/mytheme/single.php on line 7
 * Which doesn’t make any sense to me, because that’s part of the parameter. Can
   someone tell me what I’m doing wrong?

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

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/custom-loop-question-1/#post-2367371)
 * Why would you query single.php like this? It’s normal for single.php to just 
   show one post.
    You used the wrong quotes in `$myPosts->query(’posts_per_page
   =1’);` change it to this: `$myPosts->query('posts_per_page=1');`
 *  Thread Starter [wplearner](https://wordpress.org/support/users/wordpresslearner/)
 * (@wordpresslearner)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/custom-loop-question-1/#post-2367581)
 * hey thanks much Keesie, had no idea there are different types of single quotes.
   But how did you get the non slanted ones? also I’m really just trying to experiment
   with different parameters though I take your point.
 *  Thread Starter [wplearner](https://wordpress.org/support/users/wordpresslearner/)
 * (@wordpresslearner)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/custom-loop-question-1/#post-2367582)
 * hmm, maybe it’s because I was editing it from within the host server and it’s
   doing some weird formating.

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

The topic ‘custom loop question’ is closed to new replies.

## Tags

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

 * 3 replies
 * 2 participants
 * Last reply from: [wplearner](https://wordpress.org/support/users/wordpresslearner/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/custom-loop-question-1/#post-2367582)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
