bhenbe
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: WP_Query date filter for a dayOk, i just found what’s wrong. By default, WP_QUERY preprend sticky posts in archives.
With the ignore_sticky_post argument, it works.
-> http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters
Forum: Fixing WordPress
In reply to: WP_Query date filter for a dayI tried the plugin debug-queries to show all queries.
There’s something strange. The following code generates two queries :
$search = new WP_Query( $args );The result :
Query: SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wjp_posts WHERE 1=1 AND ( ( YEAR( wp_posts.post_date ) = 2015 AND MONTH( wp_posts.post_date ) = 10 AND DAYOFMONTH( wp_posts.post_date ) = 4 ) ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'acf-disabled' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 10 Call from: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/mysite/archive.php'), my_get_post_count_by_date, WP_Query->__construct, WP_Query->query, WP_Query->get_posts Query: SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID IN (167,26) AND wp_posts.post_type = 'post' AND ((wp_posts.post_status = 'publish')) ORDER BY wp_posts.post_date DESC Call from: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/mysite/archive.php'), my_get_post_count_by_date, WP_Query->__construct, WP_Query->query, WP_Query->get_posts, get_posts, WP_Query->query, WP_Query->get_postsThe ids in the seconth query are the two only featured posts.
Forum: Fixing WordPress
In reply to: WP_Query date filter for a daySorry, i don’t rename this function. A better name will be check_if_post_by_date or something like that. My custom theme is not finished.
I use a jquery datepicker on the archive page and i need to check wich days have posts to don’t link to a 404.
It seems there’s no call to a pre_get_post in my custom theme.
I have five posts for my test : 3 on the 30th september and 2 on the 1st october.
I added this to see the return value :
while ( $search->have_posts() ) { $search->the_post(); $current_date = get_the_date('n-j-Y', get_the_id()); var_dump($current_date); }And here’s the return value for the empty days (2th to 31th october) :
string(9) "10-1-2015" string(9) "9-30-2015"Finally, i printed the query :
SELECT SQL_CALC_FOUND_ROWS WP_POSTS.ID FROM WP_POSTS WHERE 1=1 AND ( ( YEAR( WP_POSTS.POST_DATE ) = 2015 AND MONTH( WP_POSTS.POST_DATE ) = 10 ) ) AND WP_POSTS.POST_TYPE = 'POST' AND (WP_POSTS.POST_STATUS = 'PUBLISH' OR WP_POSTS.POST_STATUS = 'ACF-DISABLED' OR WP_POSTS.POST_STATUS = 'PRIVATE') ORDER BY WP_POSTS.POST_DATE DESC LIMIT 0, 10`
There’s no information about the day and i don’t understand why.