Skip Navigation

[Resuelto] get published date of post used in post relationship

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 7 años. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Etiquetado: 

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por marcB-6 hace 7 años.

Asistido por: Minesh.

Autor
Mensajes
#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

Idiomas: Inglés (English )

Zona horaria: 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

Idiomas: Inglés (English )

Zona horaria: 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