• phe.le

    (@phele)


    Hi,

    I’m currently using the post_where filter to get posts from specific date period. For some reason, it does not work with offset. Have anyone done something like this before?

    <?php
    function filter_where($where = '') {
    	//posts in the last 10 days
    	//$where .= " AND post_date > '" . date('Y-m-d', strtotime('-11 days')) . "'";
    	//posts  30 to 60 days old
    	$where .= " AND post_date >= '" . date('Y-m-d', strtotime('-21 days')) . "'" . " AND post_date <= '" . date('Y-m-d', strtotime('-11 days')) . "'";
    	//posts for March 1 to March 15, 2009
    	//$where .= " AND post_date >= '2009-03-01' AND post_date <= '2009-03-15'";
    	return $where;
    }
    add_filter('posts_where', 'filter_where');
    query_posts( 'cat=-3,-19,-88&offset=6&showposts=-1' );
    ?>

    posts_where: http://codex.ww.wp.xz.cn/Plugin_API/Filter_Reference/posts_where

    http://ww.wp.xz.cn/support/topic/show-the-posts-published-before-a-specific-date?replies=2#post-1066144

The topic ‘WordPress posts_where and Offset’ is closed to new replies.