WordPress.org

Support

Support » Plugins and Hacks » Hacks » can't see why 'monthnum' parameter being ignored

can't see why 'monthnum' parameter being ignored

  • 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() ) {
            $query->the_post();
            my_print_post();
        }
        echo '</div>';
        exit();
    }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘can't see why 'monthnum' parameter being ignored’ is closed to new replies.