Hello team,
I have a custom post type "avtaler". I have also created a field group with a rfg (nedlastbare-filer). Inside the rfg I have multiple fields, including a toolset date field (dato).
I want to display and sort all rfg-fields for all the post in one list, sorted by date. (newest on top).
Can you help me in the right direction how to solve this?
Hello,
It is possible with classic view, for example:
1) Dashboard-> Toolset-> Settings-> General, in section "Editing experience", enable option: Show both the legacy and Blocks interface and let me choose which to use for each item I build
2) Dashboard-> Toolset-> Views, create a post view:
- Query posts of your repeatable field group
- Order the result by post date
- do not need other filter
- In view's loop, display the post information + custom fields
Thanks for your reply. I want to achive the same thing with php. Can you tell me how to construct the WP query to achive the same thing as you guided me for views.
Thanks 🙂
Best!
Svein
You can follow WP document to setup your custom PHP codes:
https://developer.wordpress.org/reference/classes/wp_query/
For example:
$args = array(
'post_type' => 'my-rfg-slug', // The repeatable field group slug
);
$query = new WP_Query( $args );
And you can also render the post view with in your custom PHP codes, for example:
$args = array(
'name' => 'your-post-view-slug',
);
echo render_view( $args );
More help:
https://toolset.com/documentation/programmer-reference/views-api/#render_view
Renders a View and returns the HTML output.