Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Joe Siegler

    (@joe-siegler)

    Also, I looked under “Further Customizations” on this page:

    https://www.billerickson.net/shortcode-to-display-posts/

    It says it has an example showing this, but there doesn’t appear to be anything on the page.

    Plugin Author Bill Erickson

    (@billerickson)

    Sorry for the broken examples on that post, I’ve updated it.

    As of right now there’s no easy way to query posts based on a date range. There’s a few examples using the posts_where filter on the WP_Query Codex page.

    In WP 3.4 or 3.5 we should have improved date arguments for WP_Query.

    The way I would approach this now would be to store the post date as a UNIX timestamp in postmeta, then do queries based on it.

    Create a metabox using this CMB library that uses the ‘text_date_timestamp’ field, which stores the date as a UNIX timestamp.

    OR

    Write a function that automatically creates this field when you publish a post. Here’s an example of something similar I wrote for converting Gravity Forms submsisions dates into unix timestamps: https://www.billerickson.net/code/gravity-forms-unix-timestamp/

    THEN

    Add two fields to your shortcode, like [display-posts start_date=”04-11-11″ end_date=”04-30-11″]. Write an output filter that grabs these values, converts them to unix timestamps, then do a query based on them. Something like this: https://www.billerickson.net/code/event-query/

    As you can see, this is definitely not a simple addition.

    Thread Starter Joe Siegler

    (@joe-siegler)

    Yeah, I was afraid of that. Was looking for something quick. I could probably muddle through it if I spent a ton of time, but I don’t have time. I’ll probably just have to go with the big list for now and adapt it later on when I have time to mess with it.

    Tkx for looking.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Display Posts Shortcode] Using a Date Range’ is closed to new replies.