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!
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.
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...
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/
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?
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. **
Thank you Jamal friend, for contacting the team for me. It's now working nicely 🙂
Cheers!
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.
My issue is resolved now. Thank you!