Title: WP Query problem
Last modified: August 20, 2016

---

# WP Query problem

 *  [Trevsweb](https://wordpress.org/support/users/trevsweb/)
 * (@trevsweb)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/wp-query-problem/)
 * have a WP Query question. basically got a list of articles with a certain issue
   number custom field grissue.
 * the query is supposed to get the issue number the page is currently on for aguments
   sake “119” and list all of the 119 issues articles.. a bit like a contents page.
 * now i have added issue 120 its started to mix within the list of issue 119 totally
   ignoring the custom field.
 *     ```
       $key = "grissue"; $grissue = get_post_meta($post->ID, $key, true);
       $query = new WP_Query( array ( 'post_type' => 'customposttypename','posts_per_page' => '-1', 'orderby' => 'menu_order', 'order' => 'ASC', 'meta_key' => 'grissue', 'meta_value' => $grissue ) );
       ```
   
 * if i put the issue number in like so
    `$grissue = "120";` above the query. it
   works fine… but removes the whole dynamic nature i was going for… dont know if
   my query is messed up or not but bit disheartened after all the work i put into
   this 🙁
 * can anyone help?

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/wp-query-problem/#post-2278440)
 * what is the value of $grissue after this line:
 *     ```
       $grissue = get_post_meta($post->ID, $key, true);
       ```
   
 * i.e what is the output if you add some code like this:
    `echo $grissue;` or even
   more basic, what is the output of: `echo $post->ID;` before that line?
 * where is your whole code section in relation to the full template?
 *  Thread Starter [Trevsweb](https://wordpress.org/support/users/trevsweb/)
 * (@trevsweb)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/wp-query-problem/#post-2278442)
 * should be a string of 120 or 119 depending on what page it is
 * just studied the codex (god i love that) think ive found the solution
    replaced
   the meta query variables for the meta query
 * `'meta_query' => array(array('key' => 'grissue','value' => $grissueno ))`
 * hope its solves the problem

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

The topic ‘WP Query problem’ is closed to new replies.

 * 2 replies
 * 2 participants
 * Last reply from: [Trevsweb](https://wordpress.org/support/users/trevsweb/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/wp-query-problem/#post-2278442)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
