Title: query_posts() Variables as Arguments
Last modified: August 21, 2016

---

# query_posts() Variables as Arguments

 *  [DZaidle](https://wordpress.org/support/users/dzaidle/)
 * (@dzaidle)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/query_posts-variables-as-arguments/)
 * The following works perfectly:
 * `$current_issue = query_posts('tag=April+2012&category_name=Cover');`
 * What I cannot get to work is:
 * `
    $tag_var = 'April+2012';
 * $current_issue = query_posts("tag=$tag_var&category_name=Cover");
 * I’ve tried multiple variations such as:
    ` $tag_var = 'April+2012';
 * $current_issue = query_posts('tag='.$tag_var.'&category_name=Cover');
 * But nothing works. I get either an empty array or the fisrst “n” posts (where“
   n” = the default posts-per-page setting)
 * Kudos and accolades for any help to make this work.

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

 *  [simple1](https://wordpress.org/support/users/simple1/)
 * (@simple1)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/query_posts-variables-as-arguments/#post-3702561)
 * I’m interested in how this might work also.
 *  [David Choi](https://wordpress.org/support/users/wpthemes777/)
 * (@wpthemes777)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/query_posts-variables-as-arguments/#post-3702562)
 * Try
 * `$current_issue = query_posts("tag={$tag_var}&category_name=Cover");`
 * So the PHP variable can be parsed when double quotes ” are used.
 * [http://php.net/manual/en/language.types.string.php](http://php.net/manual/en/language.types.string.php)

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

The topic ‘query_posts() Variables as Arguments’ is closed to new replies.

## Tags

 * [arguments](https://wordpress.org/support/topic-tag/arguments/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [variables](https://wordpress.org/support/topic-tag/variables/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [David Choi](https://wordpress.org/support/users/wpthemes777/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/query_posts-variables-as-arguments/#post-3702562)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
