I have a one-to-many post relationship. Now I would like to display a custom post field of a parent post, where views loads the last post depending on a date, which is given in a related child post.
So..
I have an event (parent).
This event has one or more "game days" (child).
Now I would like to display the newest event, depending on the nearest game day from today on home (only one, so view is limited to 1).
That works so far with view.
Problem:
sometime we have a post in pending mode, so it should not be visible to anyone.
I can manage this with this code:
[wpv–conditional if="( '[wpv-post-status item='@cptslug.parent']' ne 'pending' )"]
code here
[/wpv–conditional]
It hides the pending/draft post but also doesn't show any other event. How can i display the first event, which complies all requirements (next date (=game day) and published parent post)?
Hello. Thank you for contacting the Toolset support.
Well - I think I already have your one ticket assigned.
How can i display the first event, which compiles all requirements (next date (=game day) and published parent post)?
==> I do not understand the question you shared above. Could you please explain with test case example? Once I understand your requirement I would be happy to guide you in the right direction.
well, on home (lien caché) we have a picture on the top (now it is blue with red letters). This image is from one event (slug: produktion) and is loaded by the date of its child posts (spieltermin). That works so far.
Problem:
If my client wants to add but not publish a new event, it is shown there, so we tried to filter it by post-status "if parent post status is publish, show it, if not, call the next available event where parent post status is on publish." But we are not able to manage this because view displays (or hides) only the first event and doesnt jump to the next possible event which fullfills the requirements of "parent post status = publish" and "spieltermin = is the nearest in the future"
Thanks but unfortunately the problem persists. It displays the newest image although its parent post has post status "draft".
It should call the next available event, where parent post status is on "publish" instaed.
Please note that there is no way to take next step if parent post has draft status or switch to another post if there is no matching child posts should be matched to date field. The thing is that either you can query post with limit or query all posts. You can not break the loop in middle.
So, what we are doing, we are finding parent post with status=publish and then we are querying its related child post based on date condition and if found, it will display the results, as you can see its currently display the result.
This is not working, as we need the date of "spieltermin" to order the post-image.
Maybe it is possible to only save the child post on creating as draft instead of publish it automatically? Then we could filter it by child post status.
Well - whatever but when you set the post as the draft, it will create the issue with the relationship.
And I do not see this is logical as well, because you have one To many relationship between your post type. The only way to achieve this is using the custom query which needs custom programming that is beyond the scope of our support policy.
I think you need to look at your structure or consult some experts.
And as I acknowledge that there is no way to switch the view's loop in such cases like " if parent post has draft status or switch to another post".