Restrict query to last day with posts

You need to find the most recent date with posts and use that to construct the $current_ fields. $last_date = $wpdb->get_var(“SELECT DATE(MAX(post_date)) FROM {$wpdb->posts} LIMIT 1”); if (!empty($last_date)) { list($current_year,$current_month,$current_day) = explode(‘-‘,$last_date); query_posts( “cat=5&year=$current_year&monthnum=$current_month&day=$current_day&order=ASC” ); }

Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months

First of all I don’t think you should use your custom query_posts in here. WordPress already queries posts on archive pages, so it’s waste of time to query them one more time. You should be using pre_get_posts filter. function my_pre_get_posts($query) { if (!is_admin() && is_main_query() ‘<YOUR_POST_TYPE>’ === $query->query_vars(‘post_type’) && $query->is_archive()) { $query->set(‘orderby’,’meta_value’); $query->set(‘meta_key’, ‘<YOUR_POST_TYPE>’); //formatted … Read more

If Posted After Date

There are many ways of comparing dates. the following is perhaps the simplest (untested): if ( in_category( ‘photographer-interviews’ ) && strtotime( get_the_date( ‘c’ ) ) > 1376524800 ) { get_template_part( ‘content’, ‘interview’ ); } else { get_template_part( ‘content’, ‘blog’ ); } 1376524800 is the Unix timestamp for 00:00 (GMT) on August 15 – that is, … Read more

WordPress Custom Search Form Displaying Unexpected Results

You are likely getting unexpected results due to your query string. I would recommend getting familiar with the following: List of WordPress Query Variables WordPress function: get_query_var($var); List of WordPress Reserved Terms. Reserved Terms Avoiding the following reserved terms is particularly important if you are passing the term through the $_GET or $_POST array. Doing … Read more

How would I use this filter to change the output of the date format to “Twitter time”?

WordPress has a core function human_time_diff that does what you want, using it with the filter you provide you have someting like so: add_filter(‘latest_tweets_render_date’, function( $created_at ){ $date = DateTime::createFromFormat(‘D M d H:i:s O Y’, $created_at ); return sprintf( ‘%s ‘ . __( ‘ago’ ), human_time_diff( $date->format(‘U’) ) ); });

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