ACF field order
-
How can I order the Recent post on ACF field (release date <- I created)?
-
Hello Timmel789,
You will need to specify the “Meta Key” widget parameter to the “Field Name” of the corresponding ACF field. Then you will have to set “Orderby” to “Meta Value Numeric”.
This assumes your ACF date field is set to defaults, (is saved in the default format) if it’s not, without custom coding the code may return errors.
Regards,
RafalThnx for you support. It works. Is it also possible to:
if (Relasedate <- i created ) = older then today -> don’t show?
Regards
Hey Timmel789,
No it’s not. This is supported for the post publish date only.
Why? The reason for that is the fact that meta key and values can be any string which has a lot of different conditions that apply: hhttps://codex.ww.wp.xz.cn/Class_Reference/WP_Query#Custom_Field_Parameters
This however may be added later on in a future release. I’d still like to see the others looking for such a feature.
Anyway I think that Meta Query parameters added to the widget are a good idea.
Regards,
RafalOkay thnx,
I guess I have to edit the code of the plugin.
Can you give me a hit where I have to add the if statement?Regards,
Hey,
You’ll have to modify the ACF_Rpw_Widget::_get_query_args method.
It’s located inside the acf-widget/classes/acf-widget-widget.php file. You’d need to modify the already existing Tax Query (L#375 and #387), which applies only if there’s a Post Format setting checked. If it’s not then you’d have to add it on your own. Quite complex, requires reverse engineering.
I’ll be able to code this feature at most by the end of the first week of May.
Okay thanks for the Tip.
This feature would be super handy. Can’t find a plugin that has a feature where it is possible to create complexer statements for people with no coding knowledge. Would be a great value to the plugin. Thanks 🙂
Regards,
Alright then,
This’ll be done in the first week of May.
Hello Timmel789,
The plugin has been updated with the requested.
You’ll see two new fields added here: http://screencast.com/t/iiFVKB9Rad. Meta Compare and Meta Value.
You can now specify your custom field and compare it with any other field. For instance such an application: http://screencast.com/t/wGOfVgAv allowed me to compare the ACF date field (with the default save format) with the tomorrow’s date.
The [date] shortcode. Will simply output the current date. Optionally you can specify the parameter, which corresponds to the arguments of this function: http://php.net/manual/pl/function.strtotime.php that will relate the date from today any period back or further.
Let me know if you have any questions. In my sample I’ve checked the code with ACF and it lists only posts which have the acf_date field higher than tomorrow.
Cheers,
RafalGreat thanks,
I’ll test it and let you know if I find any bugs
Great,
It works perfectly.
Maybe for the future its a great idea to add more shortcodes for other users.Thmx for the great work.
Perfect mate 🙂
Shortcodes, that is, the shortcode placed in the content? With the amount of options to select from I didn’t see any application to create the shortcode actually. You’d have to specify a lot of options and HTML textareas might end up in unexpected results with the shortcode parser 🙂
The topic ‘ACF field order’ is closed to new replies.