Title: Date Range, Custom Field.. ?
Last modified: August 19, 2016

---

# Date Range, Custom Field.. ?

 *  [brianj-1](https://wordpress.org/support/users/brianj-1/)
 * (@brianj-1)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/date-range-custom-field/)
 * Hi, i’m using WordPress with a custom field **Publishing_Date** as a books database.
 * Now i’d like to have 3 Buttons: **available – soon – upcoming**
 * Any ideas how to display such a *Date Range* as a category?
 * Thanks in advance

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [brianj-1](https://wordpress.org/support/users/brianj-1/)
 * (@brianj-1)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/date-range-custom-field/#post-1191567)
 * …anyone?
 *  [s_ha_dum](https://wordpress.org/support/users/apljdi/)
 * (@apljdi)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/date-range-custom-field/#post-1191568)
 * To actually connect these fields to a Category would be tricky because the posts
   would have to change category automatically as dates change. Its not impossible
   though. You’d need a script to assign a category on post/edit and a script to
   reassign categories each day.
 * I think it would be easier and cleaner to create a new theme template for the
   display of your ‘available – soon – upcoming’ books. Inside the template, query
   the DB for ‘available’, ‘soon’ or ‘upcoming’ depending on circumstances and spit
   out the posts. I don’t think [query_posts](http://codex.wordpress.org/Template_Tags/query_posts)
   will do it for you because you’ll need to search the DB by date ranges, but it
   shouldn’t be a hard query to write.
 *  Thread Starter [brianj-1](https://wordpress.org/support/users/brianj-1/)
 * (@brianj-1)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/date-range-custom-field/#post-1191570)
 * Hmm sounds difficult.. actually my category.php loads theme templates like this:
 * >  //category.php
   >  <?php if (is_category(1)) { include(TEMPLATEPATH . ‘/category-
   > 1.php’);} ?>
 * >  //category-1.php
   >  <?php if (have_posts()) : while (have_posts()) : the_post();?
   > >
 * So how to change that query to load post based on custom field values?
 *  Thread Starter [brianj-1](https://wordpress.org/support/users/brianj-1/)
 * (@brianj-1)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/date-range-custom-field/#post-1191625)
 * still havn’t found solution… anyone?
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/date-range-custom-field/#post-1191626)
 * If you are storing the date in your custom field in a format such as year-month-
   day (e.g. 20091006 for Oct 10, 2009) then you can use the [query_posts() Custom Field arguments](http://codex.wordpress.org/Template_Tags/query_posts#Custom_Field_Parameters)
   to filter your dates. Otherwise you’d need to use [wpdb](http://codex.wordpress.org/wpdb)
   and craft a SQL statement that does a join with wp_posts and wp_postmeta with
   a LIKE filter.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Date Range, Custom Field.. ?’ is closed to new replies.

## Tags

 * [publishing date](https://wordpress.org/support/topic-tag/publishing-date/)

 * 5 replies
 * 3 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/date-range-custom-field/#post-1191626)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
