Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm dynamically building a query into a variable called $qstring and then executing it

When it looks like post_type=post&posts_per_page=4&order_by=modified&monthnum =12&year=2012&offset=8 it pulls back everything from 2012, rather than just December.

Is there something amiss with my query formatting? It is in an ajax call so nothing else should be interfering with it.

The whole function looks like this:

function load_more(){
    $offset = $_REQUEST['offset'];

    $qstring = 'post_type=post&posts_per_page=4&order_by=modified';

    if (isset($_REQUEST['cat'])){ $qstring .= '&cat='.$_REQUEST['cat'];}
    if (isset($_REQUEST['tag'])){ $qstring .= '&tag_id='.$_REQUEST['tag'];}
    if (isset($_REQUEST['month'])){ $qstring .= '&monthnum ='.$_REQUEST['month'];}
    if (isset($_REQUEST['year'])){ $qstring .= '&year='.$_REQUEST['year'];}

    $qstring .= '&offset='.$offset;
    echo '<div>';
    // echo '<p>'.$qstring.'</p>';
    $query = new WP_Query( $qstring );
    $result = null;
    while ( $query->have_posts() ) {
        $query->the_post();
        my_print_post();
    }
    echo '</div>';
    exit();
}
share|improve this question

closed as too localized by toscho Dec 9 '12 at 11:01

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

There was a space between monthnum and its equals sign.

carry on folks...

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.