Wp_Query dates before xxxx-xx-xx
-
I’m trying to create a loop of posts of the current author that are dated on or before the current page’s published date.
My query params:
$query = array( 'posts_per_page' => 3, //number of results 'author' => $post->post_author, //only this author 'post__not_in' => array($post->ID), //NOT this post 'cat' => '513,517,1151,8690', //from this category 'post_type' => 'post', //only posts 'dated_before' => '2010-01-01' //DESIRED QUERY PARAMETER );
Here is the
posts_where
filter that I’m attempting to use:function dg_dated_before($where) { global $wp_query; if ($wp_query->query_vars['dated_before']): $where = $where . " AND posts.post_date <= '". $wp_query->query_vars['dated_before'] . "' " ; endif; return $where ; } add_filter('posts_where', 'dg_dated_before') ;
But obviously, it doesn’t work, else I wouldn’t post it here ??
Thoughts?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Wp_Query dates before xxxx-xx-xx’ is closed to new replies.