Skip Navigation

[Resolved] Problems on Post Parent

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to get the post parent of the same post type using PHP.

Solution:
This can be done by using the function below.
$parent_id = wp_get_post_parent_id( get_the_ID() );

This works when the post parent is the Same Post Type.

This support ticket is created 5 years, 11 months ago. 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)

This topic contains 19 replies, has 2 voices.

Last updated by santiagoF 5 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#1165911
001.jpg

Hi, the parent is: hidden link

The Child: hidden link

Check video:
hidden link

#1166330

Shane
Supporter

Languages: English (English )

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

Hi Santiago,

Thanks, I'm a little clearer now.

So on this Same Post Type Parent/Child relationship, you want to display the Child of the Parent on the child of the Native wordpress relationship.

Essentially displaying Karen Goldman on this page. hidden link

Correct?

#1166444

Hi @Shane, it's correct!
Karen must appear on this page: hidden link

Thanks!

#1166487

Shane
Supporter

Languages: English (English )

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

Hi Santiago,

I managed to resolved this by using this shortcode.

// Add Shortcode
function wp_get_parentid() {

	$parent_id = wp_get_post_parent_id( get_the_ID() );
	
	return $parent_id;

}
add_shortcode( 'wp_get_parentid', 'wp_get_parentid' );

Add it to your functions.php file and you can use it like this [wp_get_parentid]

Next I added it to the views 3rd party shortcode arguements in Toolset -> Settings - Frontend

Finally I changed the relationship filter to get the parent ID from the shortcode attribute, which resulted in a shortcode like this.
{!{wpv-view name='docentes-del-curso'  wpvrelatedto='[wp_get_parentid]' orderby='titúlo'  order='asc' cached='off'}!}

Also you may need to remake the post for Karen Goldman
Please let me know if this helps.

Thanks,
Shane

#1167673

My issue is resolved now. Thank you!