Posted: February 18, 2015 at 9:48 am
Just need to display events by their Event start date. Is my orderby parameter wrong?
|
|
Hi Peyton, The get_posts() function’s orderby parameter accepts the values listed here: http://codex.wordpress.org/Template_Tags/get_posts#Parameters |
|
Sorry, almost there. You guys have been a big help. I’m just trying to wade through your examples in your different queries. This one doesn’t sort by start date but displays the start date exactly like I want just need it to sort correctly.
This Query (taken from your example) sorts by start date, but it displays the “on sale date”, instead of the start date like I want.
Just looking to sort by start date, and display the start date in any kind of query. Thanks so much |
|
Hi Peyton, So in your first example, please note that the orderby parameter for get_posts will not accept start_date. In your second example, I tried to load your code up into a page template and it threw a fatal error. Then I changed where you have:
and that allowed the event list to display. Along with that, I can verify that |
|
Ah, ok. Great. But what if I have Multiple date times for the event? Here you can see what I have: I’ve changed the show expired parameter to FALSE, and I guess because the event is truly not expired, because it has later dates, it still shows the first date, which is expired and is a little confusing. Thanks in advance. |
|
Hi there, It’s actually because the you’re using the get_primary_date_obj() method. That’s always going to the display the primary, or first added datetime for an event. If you look at the code I shared with you in your other thread, you’ll see an example of how to get the next upcoming datetime for an event: |
|
And that makes sense. Thank you. |
|
The support post ‘Orderby in cusotm Query’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.