• Hi guys,
    I’m working on this website where the homepage is composed of both events (managed using the Events Calendar plugin) and articles. Currently, both are sorted by creation date.

    I’d like to have the events sorted by their start date, while I’d like to order the articles by their creation date (still with both on the same page). How do I accomplish this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    One way I can think of would be using WP_Query. Create one query for the events and the other for the articles/posts.

    Thread Starter Mirek2

    (@mirek2)

    I should mention that I want the articles to appear among the events. (For example, say one event takes place on Jan. 5, another on Jan. 7, but both events were created on Jan. 2. If I create an article on Jan. 6, I want it to appear in between the two events.)
    Is that possible with WP_Query?

    Moderator bcworkz

    (@bcworkz)

    Not entirely. You’ll need to filter ‘posts_orderby’ to insert a complex orderby clause. WP_Query should form the remainder of your query just fine though.

    I’m unsure of what that complex clause would be, or if it’s even possible. Some sort of sub-query that returns one date or the other depending on the post type or whatever distinguishes articles from events.

    If that doesn’t work, you could sort the returned array with PHP and usort().

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom post order’ is closed to new replies.