Query current and future events, ordered by begin date

This happens because of the OR relation on meta_query and the way WordPress generates the actual query string. You need to leave out the meta_key and orderby from the query args and hook into the posts_clauses filter to modify the where and orderby pieces of the query: function wpse_130954_orderby_fix($pieces){ global $wpdb; $pieces[‘where’] .= ” AND … Read more

Date query not inclusive despite parameter being true

If you only want to work with yyyy-mm-dd strings, for example ‘2014-10-10’, you could do something like: ‘before’ => ‘2014-10-10 + 1 day – 1 second’, ‘before’ => ‘2014-10-10 + 86399 seconds’, ‘before’ => ‘tomorrow 2014-10-10 – 1 second’, ‘before’ => ‘2014-10-10 tomorrow – 1 second’, or just append ’23:59:59′ to your yyyy-mm-dd string to … Read more

Remove “at” string from wordpress comment date

Most likely, the ‘at’ is coming from the value of $comment->comment_date. If that is the case, and since we have to do with string, you could pass it from str_replace first, in order to remove the ‘ at’, like: function my_change_comment_date_format( $date, $date_format, $comment ) { return date( ‘d M Y’, strtotime( str_replace(” at”, “”, … Read more

How can I display a specific user’s first published post?

The following query retrieves the oldest post of a specified user/author: $user_id = 42; // or whatever it is $args = array( ‘posts_per_page’ => 1, ‘post_status’ => ‘publish’, ‘author’ => $user_id, ‘orderby’ => ‘date’, ‘order’ => ‘ASC’, ); $first_post = new WP_Query($args); if ($first_post->have_posts()) { $first_post->the_post(); // Now you can use `the_title();` etc. wp_reset_postdata(); } … Read more

How to make an archive page displaying posts in a date range

Saving the date in post meta is a slightly more sane approach, the post_date column was not designed with your use case in mind. You may get weird results with dates before the Unix epoch (January 1, 1970). Then it’s just a simple meta_query to load posts between dates, no filter necessary. $start=”1900-01-01″; $end = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)