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’) ) ); });

Changing default WP-Site creation date

There is no blog creation date in WordPress. The first blog post is usually regarded as the blog creation date when you create copyright footer notes for a blog. This is not very reliable though. There are a few thing that happens by default when WordPress is first installed, the most important being a user … Read more

empty query breaks other queries

Before we start, you should properly indent your code and remove php spam. This makes your code much easier to read and understand. Secondly, rather use curlies ({}) instead of syntax like :, endif and endwhile. It is easier to debug and to read. Just another tip, comment your code for future reference, it makes … Read more