July 4, 2018 at 1:25 am #5108
Just wondering if I can order the Show Posts results by a Custom Field set up through ACF for a custom post type?
BenJuly 4, 2018 at 6:30 pm #5128
You could try this:
[wp_show_posts id="123" settings="orderby=meta_value&order=DESC"]
That’s according to these instructions: https://www.advancedcustomfields.com/resources/orde-posts-by-custom-fields/July 12, 2018 at 5:27 pm #5237
Thanks – didn’t see you had posted this, will give it a try.
BenJuly 12, 2018 at 5:56 pm #5239
It works! Once again you’ve come to the rescue – thanks so much, your help is really appreciated.
For anyone else looking to do the same thing, here is the shortcode I ended up with. Needed to add the meta_key to the above code.
Note the meta_key is the name of the Custom Field, in my case it was event_id.
[wp_show_posts id=”16″ settings=”meta_key=event_id&orderby=meta_value&order=ASC”]
BenJuly 12, 2018 at 7:31 pm #5243
Glad you got it working! Thanks for sharing your code 🙂July 17, 2018 at 6:30 pm #5282
Sorry to bring this up again. I’m having an issue with this method and was wondering if you could shed any light.
The code works OK when I use a WPSP List to show all posts for my CPT (Events)(eg. https://www.orangewinefestival.com.au/event-program/events-program/), but when I choose a taxonomy (event_type) it stops working (eg. https://www.orangewinefestival.com.au/event-program/weekday-events/).
I am using a custom field to sort by, a field I have created called event_id, which is a number field. I tried setting that as a text field but it didn’t fix the issue.
If I change to order by field in WPSP List settings then the order will change, so it appears that when a Custom Taxonomy is being used, the ‘settings’ part of the shortcode is being ignored.
BenJuly 18, 2018 at 6:35 pm #5297
Further to this, I am having an issue with the sorting on a non-custom field – ID. If you have a look at this page (https://www.orangewinefestival.com.au/event-program/weekend-two-events/), you will see numbers at the bottom of each event (882, 883 etc) these are the ID’s for each Event, using get_the_ID(). Notice that even though I am ordering by ID, set to ASC, it isn’t working.
Note I have removed the ‘settings’ from my WPSP shortcode, so it’s just [wp_show_posts id=”27″ ]
Also when I set the order in WPSP to DESC it changes the order, but it still isn’t correct.
This is getting to be an urgent issue now so any help would be appreciated – thanks.
BenJuly 18, 2018 at 8:19 pm #5301
Can you try editing the plugin to test something?:
And replace it with:
'orderby' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_orderby' ) ),
Let me know if that works or not.July 19, 2018 at 4:58 am #5312
Thanks Tom, that seems to have worked. You’re a lifesaver (again!).
Anything else I should do?July 19, 2018 at 8:02 pm #5315
Awesome! Nope, I’ll get that added by default in the next version 🙂
- You must be logged in to reply to this topic.