WordPress.org

Ready to get started?Download WordPress

Forums

How do I center WordPress blog to order posts ascending from the present? (3 posts)

  1. Josh Rosenau
    Member
    Posted 4 months ago #

    I am building an events blog that has events in future and in the past. As a result, I want for my theme to start at the coming post (future post) nearest to the present. Then, I want readers to be able to move forward in the future and backward in the past, beginning at the blog post closest to NOW.

    It's like a number line, where the reader starts at [0]. Like so:
    <-----------------------start------------------------------>
    -9-8-7-6-5-4-3-2-1 [0] +1+2+3+4+5+6+7+8+9

    The problem, of course is that [0] is always shifting, as are the posts' relationships to [0].

    I've already set up my theme to allow me to publish posts with future dates.

    The problem I am running into is that when I use a parameter like "from" or "after", there is a hard cutoff that removes the past content.

    The resulting number line looks like: [0] +1+2+3+4+5+6+7+8+9. -- which is no good.

    I was using this doc for help.

    Maybe two separate scripts defining post order ASC and DESC are called for here???

    I don't know if that's possible to arrange without the post orders contradicting one another.

    As always, thanks to anyone who can help!

  2. Devin Price
    Member
    Posted 4 months ago #

    I wouldn't use the post date as the event date. I would create a separate meta field to hold the event date start and end and query against that.

    http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters

    You can pull upcoming events by using the current timestamp to query again the event date custom field ASC. Or, already passed events by querying DESC.

    I'd also suggest looking at how other developers have solved the issue: http://wordpress.org/plugins/sugar-calendar-lite/

  3. Josh Rosenau
    Member
    Posted 4 months ago #

    Sorry, but I need the post date to be the event date.

Reply

You must log in to post.

About this Topic