Title: php query_posts syntax error (should be very easy:-)
Last modified: August 20, 2016

---

# php query_posts syntax error (should be very easy:-)

 *  [benwake](https://wordpress.org/support/users/benwake/)
 * (@benwake)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/php-query_posts-syntax-error-should-be-very-easy/)
 * Hi everyone,
 * I have this line in my index.php for getting all the posts from a certain category:
 *     ```
       <?php query_posts('category_name=categoryname&posts_per_page=4'); ?>
       ```
   
 * I have this in my home made theme options:
 *     ```
       // Ask for category on homepage
       array( "name" => "Category home:",
        "desc" => "Enter the name of the category you want to display on the home page",
        "id" => $shortname."_category_home",
        "type" => "text",
        "std" => ""),
       ```
   
 * Now, I want the user to input the name of the category, and this should be filled
   in in the first line.
    I came up with this:
 *     ```
       <?php query_posts('category_name=echo $options['category_home']&posts_per_page=4'); ?>
       ```
   
 * This gives me a syntax error, can someone help please?
 * Thanks in advance !

Viewing 1 replies (of 1 total)

 *  Thread Starter [benwake](https://wordpress.org/support/users/benwake/)
 * (@benwake)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/php-query_posts-syntax-error-should-be-very-easy/#post-2694964)
 * I tried with this one, but no luck, he doesn’t apply the category (but applies
   the 4 posts and it removed the syntax error). Somebody? 🙂
 *     ```
       <?php query_posts('category_name='.$options['category_home'].'&posts_per_page=4'); ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘php query_posts syntax error (should be very easy:-)’ is closed to new
replies.

## Tags

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

 * 1 reply
 * 1 participant
 * Last reply from: [benwake](https://wordpress.org/support/users/benwake/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/php-query_posts-syntax-error-should-be-very-easy/#post-2694964)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
