The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

can't see why 'monthnum' parameter being ignored (3 posts)

  1. Skeary
    Posted 3 years ago #

    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... or?

    Really at a loss as to how this would not be working.

    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() ) {
        echo '</div>';
  2. bcworkz
    Posted 3 years ago #

    Just a guess, try removing the space after monthnum. You'd think the query parser would ignore spaces, but maybe not.

  3. Skeary
    Posted 3 years ago #

    That did it, thanks! Didn't notice it snuck in there..

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.