How to use orderby in shortcode
-
Hi,
I have pods custom post types “enjeu” that relate to “intervention”. I need to display interventions related to a given enjeu and order them by their “date_debut” custom field (pods date field) (desc). This is inside the single display for an enjeu.– intervention1 has post_title = “Fondation…” and date_debut = 2016-04-20
– intervention2 has post_title = “Marche…” and date_debut = 2016-08-14
I want intervention2 to show up before (above) intervention1.I do so from the pods single item widget (in Elementor pro).
This template displays the interventions (out of order, i1 then i2):
[if interventions]
<h6>Interventions:</h6>
<ul class=”fa-ul”>
[each interventions]- {@interventions.post_thumbnail}{@post_title}
[/each]
[/if]
I can call the template directly from the widget, or using this shortcode:
[pods template="enjeu_liste_interventions"]
and get the same result.If I add the orderby arg to the shortcode:
[pods name="enjeu" orderby="DATE(interventions.date_debut.meta_value) DESC" template="enjeu_liste_interventions"]
The interventions are still displayed out of order (i1 then i2).This does not seem related to the date field, as ordering by post title does not work either, still displays i1 then i2:
[pods name="enjeu" orderby="interventions.post_title DESC" template="enjeu_liste_interventions"]
It does not seem related to DESC, as setting an earlier date on i2 and order ASC still displays i1 then i2 — orderby is simply ignored.
I must have overlooked something obvious, but I can’t see it…
- The topic ‘How to use orderby in shortcode’ is closed to new replies.