Hi,
I have a custom post type for people (Tom, John, Mario, etc.).
Every person has a Repeatable Field Groups [group slug: carica-info] to define the institutional position (carica) with the start and end date.
Inside the repeatable field groups, there are two custom fields that I want to use to filter and sort the main query (Tom, John, etc.): a select [carica-organo] and a start date [carica-data-inizio].
I want to do something like this:
1) Select custom posts that have at least one repeating field with [carica-organo="director"], someone has more than one repeating field set as "director" with different start-end date.
2) Sort all the custom posts by start date.
I have also a taxonomy associated with the custom post-type and the value are the same as [carica-organo].
I'm using two views, the first one to filter the post type by category so I select every person with category=director
In the second view, I can only sort the institutional position (carica) for the current person.
Thanks in advance
Cheers
Hi there,
Thank you for contacting us and I'll be happy to assist.
The way repeating field group's data is stored in relation to its parent post, it won't be possible to add a filter to the main post type's query, based on the custom field value that is part of the repeating field group.
A neater and more efficient way to achieve this would be to replace the repeating field group with a post-relationship.
( ref: https://toolset.com/documentation/post-relationships/ )
You can remove the repeating field group "carica-info" and instead register a new custom post type with the same name "Carica Info". Any custom fields which were part of the repeating field group can be added into this new custom post type.
Next, you can create a "One-to-Many" relationship between the main "Rappresentanti" post type and the new "Carica Info" post type, so that each "Rappresentanti" post can be linked to multiple "Carica Info" posts.
After that, you'll be able to create a view that can show results ( Carica Info ), sorted on the basis of the starting date value. And inside the view, you can show the information about the connected "Rappresentanti" post.
( ref: https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/ )
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
My issue is resolved now. Thank you!