WP Group posts by year(desc) > month(desc) > date(asc)

$last_month = null; $args = array( ‘post_type’ => ‘post’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘DESC’, ‘post_status’ => ‘publish’ ); $the_query = new WP_Query($args); while ( $the_query->have_posts() ) : $the_query->the_post(); $the_month = get_the_time( ‘Ym’ ); // e.g. 201611 if ( $last_month !== $the_month ) { if ( $last_month !== null ) { // Close previously opened … Read more

Sorting a query Field by date

&orderby=date will return posts by their dates. <?php query_posts(‘post_type=page&post_parent=2&posts_per_page=-1&orderby=date&order=ASC’); ?> Replace first line with this to show post according to their date. Reference – Passing variables to query_posts Update – To sort the posts as per custom field value, Here’s the new code. query_posts(‘post_type=post&posts_per_page=-1&orderby=meta_value&meta_key=next_open_day&order=ASC’); ?> Note – The date should be saved in – YYYY-MM-DD … Read more

date issue with category post retrival

Ok I finally found the answer. The issue was caused by a strange enclosures from the podcasting plugin. Removed the enclosure and BAM everything is fine now! The main think to notice: if you have such a problem, your feed is probably invalid. Validate your feed first and then see if there are any problems … Read more

Escaping date string in url with wordpress

strtotime will return false if you give it weird information. echo strtotime(“<script>’); // bool(false) However, if you do what you are doing and nest two statement you may not get what you expect. echo strtotime(‘+1 day’,strtotime(‘<script>’)); // int(86400) And date returns the beginning of the universe, the day of creation– January 1, 1970– if given … Read more

How to order posts of a custom post type by date DESC in dashboard Admin?

Alright, You can just hook into the filter pre_get_posts and check is_admin. Put this in your theme or plugin: function wpse_81939_post_types_admin_order( $wp_query ) { if (is_admin()) { // Get the post type from the query $post_type = $wp_query->query[‘post_type’]; if ( $post_type == ‘Videos’) { $wp_query->set(‘orderby’, ‘date’); $wp_query->set(‘order’, ‘DESC’); } } } add_filter(‘pre_get_posts’, ‘wpse_81939_post_types_admin_order’); I also … Read more

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