Skip Navigation

[Resolved] Show cred-post-expiration of one-to-one child relation

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

Problem:
The user would like to display the Toolset Forms expiration date of a parent post in one-to-one relationship.

Solution:
The shortcode was not documented before. Pass the ID of the parent post to the shortcode using the item argument.

[cred-post-expiration id='[wpv-post-id item="@post-dog.parent"]' format='m/d/Y']

Relevant Documentation:

This support ticket is created 3 years, 9 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

This topic contains 8 replies, has 2 voices.

Last updated by ricardoL-4 3 years, 9 months ago.

Assisted by: Jamal.

Author
Posts
#1685247
explain2.jpg

Tell us what you are trying to do?
Hi, I'm trying to show the expiration child post date on a loop view of the relation parent post.

I've tried this shortcode but it's not really working
[cred-post-expiration id='[wpv-post-id item="@massagista-disponivel.child"]" format="d/m/Y"]

Can you help me with this?

Thank you in advance!

#1685485

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

I am not sure where the shortcode cred-post-expiration is coming from. As far as I know, Toolset does not have a shortcode to return the expiration date. Can you elaborate on this shortcode?

The expiration date is stored in a custom field "_cred_post_expiration_time" as a UNIX timestamp. So you can access its value with the following shortcode:

[wpv-post-field name='_cred_post_expiration_time' item='@massagista-disponivel.child']

But this will return the timestamp instead of a formatted date. For that reason, you will have to use a custom shortcode that will format the date. You will end up with a code such as:

[your-custom-shortcode date='[wpv-post-field name='_cred_post_expiration_time' item='@massagista-disponivel.child']']

I hope this helps. Let me know if you have any questions.

#1685517
Screenshot 2020-07-02 at 17.45.01.png

Hi Jamal, thank you for your assistance, I still have a question. Do I have to change anything to the second code you gave me?

[your-custom-shortcode date='[wpv-post-field name='_cred_post_expiration_time' item='@massagista-disponivel.child']']

For some reason, I'm getting a wrong result...

#1685529

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Yes, you will need to define the custom shortcode your-custom-shortcode, you can name it whatever you want. Read this article on how to create custom shortcodes here https://codex.wordpress.org/Shortcode_API

This shortcode will take the argument date, then it will convert it into a formatted date. Check this WordPress function https://developer.wordpress.org/reference/functions/date_i18n/

Custom code is out of the scope of our support forum, if you are not comfortable writing PHP code for the shortcode, consider hiring a developer or one of our partners.
https://toolset.com/contractors/

#1685557

Well, I'm not able to do that shortcode by myself... it out of my knowledge.

Here I saw the cred-post-expiration shortcode that Beda wrote a while ago... you can have a look within the link below:
https://toolset.com/forums/topic/cred-post-expiration-formatmdy-extract-expiry-date-to-use-elsewhere/

That's why I was wondering if I can show a child expiration date with something like that shortcode?

#1686297

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Thank you for your feedback. I followed that article and other articles. Unfortunately, the documentation that refers to the shortcode is not available anymore.
Discussing this with the team, I find out that the shortcode is provided by Toolset Forms. Toolset Forms must be active.

So I created a One-to-One relationship with two custom post types. Then I created a form with expiration for one of them. Created a post, and linked it to another post in the related custom post type. I was then able to display the expiration date of the related post with the following shortcode:

[cred-post-expiration id='[wpv-post-id item="@post-dog.parent"]' format='m/d/Y']

My relationship slug is "post-dog".
Maybe for your case, you should use "child" instead of "parent" in "@massagista-disponivel.child"

If this is not working for you, please allow me temporary access to your backend and let me check it closely. Provide more details about where do you use this shortcode(What content template or view?).
Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1686345

Thank you Jamal friend, for contacting the team for me. It's now working nicely 🙂

Cheers!

#1686353

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Awesome 🙂 I am glad we could help.

I'll have to kindly ask you to mark this ticket as resolved and open a new ticket for any other question/request/bug.

All the best with your project.

#1686357

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.