I'd like to display the expiry date of the parent post in the body of the email that is triggered by the child post. I tried [cred-post-expiration item="@relationshipslug.parent" format="d/m/Y"] but it didn't work. How do I achieve this please?
That would be fine if the expiry date I wanted to display the expiry date belonging to a specific post but I'd like to display the expiry date of the 'parent' post and this will change depending on which 'child' post is involved.
(You've enabled the 'debug info box but debug info is irrelevant; this is a general enquiry and not site specific.)
I would like to know here - do you have parent post ID available as URL param?
What I try to suggest is - you should try to find a way to get the parent post ID and then assign it to the id attribute of [cred-post-expiration] shortcode.
If you do not know how to do this, please share problem URL and access details so that I will look in to it and guide you in right direction.
do you have parent post ID available as URL param
How would this be available in the body of an email notification and how would I use it?
I've created my own shortcode to return the parent post ID (where posta-postb is the relationship slug):-
add_shortcode( 'parent_post_id', 'parent_post_id_shortcode');
function parent_post_id_shortcode( $atts ) {
global $post;
//get the parent Post ID
$parentpostid = toolset_get_related_post($post_id, 'posta-postb' );
return $parentpostid;
}
and then used the cred expiration shortcode like this:-
As I said before:
What I try to suggest is - you should try to find a way to get the parent post ID and then assign it to the id attribute of [cred-post-expiration] shortcode.
You did it using the shortcode and the way you did is also acceptable method as well.
Because - I dont know where the CRED form is added to parent post or any page or any other custom post type post. So post ID will be vary based on the situations I mention and that is why I suggested you to use shortcode so we will have accurate parent ID.
The parent post ID can be called within the [wpv-post-id] shortcode meaning it wouldn't matter where or how the child post is added to the parent. Writing a shortcode of my own is simply re-inventing the wheel. I'm surprised you're making this more difficult than it needs to be; this isn't your normal approach.