Skip Navigation

[Résolu] get published date of post used in post relationship

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
How to display child post publish date on parent post single page using view's post relationship

Solution:
You should create a view for child CPT and add query filter for this view:

filter by post relationship = Post where this View is shown 

You can find proposed solution with the following reply:
=> https://toolset.com/forums/topic/get-published-date-of-post-used-in-post-relationship/#post-591548

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/displaying-child-posts/

This support ticket is created Il y a 7 années. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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

Supporter timezone: Asia/Kolkata (GMT+05:30)

Ce sujet contient 4 réponses, a 2 voix.

Dernière mise à jour par marcB-6 Il y a 7 années.

Assisté par: Minesh.

Auteur
Publications
#591494

I have used post relationship feature for my 2 custom post types as mentioned below.

1)Lobby
2)Lobby Updates

Lobby Updates are for particular lobby which is defined using post relationship.
For example,
I have added "Lobby 1" in lobby CPT. Now, I am adding "Update 1","Update 2" in Lobby Updates and assigning "Lobby 1" in post relation ship "This Lobby update belongs to Lobby".

Sequence for adding lobby update is,
Update 1
Update 2

so, latest update would be "Update 2". I would like to display published date of recently added Lobby Update in a Lobby Detail page.

In detail page of "Lobby 1" I would like to show published date of "Update 2".

How to achieve above goal?

#591501

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - you should create a view for CPT "Lobby Updates" and add query filter for this view: filter by post relationship = Post where this View is shown and under section "Limit and Offset " select 1 and add [wpv-post-date] to display the published date in loop output editor.

#591540
Screenshot_5.png

Well, I would like to display it in a text.Please check attached screenshot.
So, just for this do I need to create separate view? Is it possible using shortcode?

#591548

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Well you have two ways.

1) I already suggested using view
2) you can build custom shortcode to fetch the latest child post. Following code may help you to understand how you fetch child post belongs to particular parent and return the post date value. You can adjust the code as per your need.

$child_args = array(
'post_type' => 'book',
'numberposts' => 1,
'orderby' => 'post_date',
'order' => 'DESC',
'meta_query' => array(array('key' => '_wpcf_belongs_writer_id', 'value' => get_the_ID()))
);
$child_posts = get_posts($child_args);

=> https://toolset.com/documentation/customizing-sites-using-php/displaying-child-posts/

#591566

Thanks. its working