Navigation überspringen

[Gelöst] change child post status when parent post status has changed

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

The issue here is that the user wanted to change the status of a child post when their parent post status is changed so that the child post isn't listed in their view.

Solution:

Unfortunately no this is not possible to do. You will need to set the child posts to pending as well manually.

What you can do however is to check the status of the parent post by using the shortcode below.
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153411

Then use the conditional shortcode to check.

So an example would be.

[wpv–conditional if="( '[wpv-post-status item='@cptslug.parent']' ne 'pending' )"]
code here
[/wpv–conditional]

So the code will check if the parent status is not pending. Now you will need to change @cptslug.parent to the slug of your parent cpt.
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/

This support ticket is created vor 6 Jahren, 3 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von alexanderL-2 vor 6 Jahren, 3 Monaten.

Assistiert von: Shane.

Author
Artikel
#1112265

Hi,
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.

Problem:
sometime we have a post in pending mode, so it should not be visible to anyone. Unfortunately it custom field will be displayed as the related child post (which is called by views) is published.

So, is it possible to change post status of a child post automatically when his related parent post status has changed to pending?

Thanks,
Alex

#1112337

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Alexander,

Thank you for contacting our support forum.

Unfortunately no this is not possible to do. You will need to set the child posts to pending as well manually.

What you can do however is to check the status of the parent post by using the shortcode below.
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153411

Then use the conditional shortcode to check.

So an example would be.

[wpv–conditional if="( '[wpv-post-status item='@cptslug.parent']' ne 'pending' )"]
code here
[/wpv–conditional]

So the code will check if the parent status is not pending. Now you will need to change @cptslug.parent to the slug of your parent cpt.
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/

Please let me know if this helps.
Thanks,
Shane

#1114156

Hi Shane,
thanks for your reply and sorry for my late response.

This shortcode works - at least in the first step.
So the thing is:

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. But if I have an "testing event" in pending/draft status, it will be also displayed on home. If i use the shortcode you provided, it hides it but doesnt show any other event. How can i display the first event, which complies all requirements (next date (=game day) and published parent post)?

Thanks!
Alex

#1114437

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Alexander,

Since the original issue of this ticket has been resolved, I would recommend that you open a second ticket with this other issue.

This will help to have our forums properly organised for other users.

Thanks,
Shane

#1114868

My initial issue is resolved now. Thank you!