Skip Navigation

[Resolved] Uncaught Error: Call to undefined function toolset_get_related_post()

This support ticket is created 6 years, 6 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
- 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)

This topic contains 6 replies, has 2 voices.

Last updated by yulyaB 6 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#919555

I am trying to: Get parent id in php

$event_id = toolset_get_related_post( $post_id, array( 'event', 'work-item' ) );

I got:
Fatal error: Uncaught Error: Call to undefined function toolset_get_related_post() ...

Relationship 'event-workitem'
event [0 .. 1] << work-item [*]

What is wrong?

#919741

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I do not understand why you are getting this error.

If you can share access details and problem URL and share the file path where you are using the function toolset_get_related_post I would be happy to debug this issue further.

#920244

hidden link
Press the button "Сертификат"

function pdfm_shortcode ($attr_a = '') {
    
    $gen_v = isset($attr_a ['v']) ? $attr_a ['v'] : 1;
    $gen_v = ($gen_v == 1 || $gen_v == 2) ? $gen_v : 1;
    
    $button_name = $gen_v == 1 ? 'Диплом' : 'Сертификат';
    
    $post_id = get_the_ID();
    
    $ax = '<a href="/?dx=' . $post_id . '_' . $gen_v . '&pdfm_create" target="_blank" class="btn btn-lg btn-primary">' . $button_name . '</a>';
    
    return $ax;
    
}

function pdfm_create () {
    
    $dx        = isset($_GET ['dx']) ? trim($_GET ['dx']) : '';
    $is_create = isset($_GET ['pdfm_create']) ? 1 : 0;
    
    if (!$is_create) return;
    elseif (!preg_match("#^(([\d]+)_(1|2))$#is", $dx, $matches)) return;
    
    $post_id = $matches [2];
    $gen_v   = $matches [3];
    
    $DOCUMENT_ROOT = $_SERVER ['DOCUMENT_ROOT'];
    
    $type_a    = array();
    
    $post_data  = get_post($post_id);
    $post_title = $post_data->post_title;
    $post_date = $post_data->post_date;
	
    $event_id = toolset_get_related_post( $post_id, array( 'event', 'work-item' ) );
    $event_meta = get_post_meta($event_id);
#920245

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - would you mind to share access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#920259

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

ahh. Well, I'm really sorry, this is totally a custom code and to debug such custom code is beyond the scope of our support policy.

I see you have wrote custom plugin and there you are trying to call the function toolset_get_related_post() and it's throwing error, it will be obvious as the needed files may not be loaded.

If you need custom programming for your project, please feel free to contact our certified partners:
=> https://toolset.com/contractors/

#920339

Ок, when i set code in fuctions.php, error disappeared, but returns null result in id of parent post.

#920720

https://toolset.com/forums/topic/get-post-parent-witn-new-relationship-model-php/
i'm find this solutions, but there is no in documentation ...
It works.