• 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

    (@brianj-1)

    …anyone?

    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 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

    (@brianj-1)

    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

    (@brianj-1)

    still havn’t found solution… anyone?

    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 to filter your dates. Otherwise you’d need to use 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.