• 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)
  • 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

    (@trevsweb)

    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.