Skip Navigation

[Résolu] Using types shortcode to provide a value to another shortcode – not working

This support ticket is created Il y a 3 années. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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: Asia/Karachi (GMT+05:00)

Ce sujet contient 5 réponses, a 2 voix.

Dernière mise à jour par alexG-4 Il y a 2 années et 12 mois.

Assisté par: Waqar.


I am using this code in a Fields and Text block

  <strong>No Shortcode - wprss_item_date:</strong> [acur_date_from_time time=1623762049]<br>
  <strong>With Shortcode - wprss_item_date:</strong> [acur_date_from_time time='[types field="wprss_item_date"][/types]']<br>
  <strong>RAW - wprss_item_date:</strong> [types field='wprss_item_date'][/types]<br>

My shortcode [acur_from_time] outputs a date when given a time in seconds.

The first line is to show that it works correctly
The second line is how I want to use it, with the time coming from a custom field.
The third line is to show that the custom field does contain a sensible value.

This image shows what appears within the block editor: it seems to be OK.

lien caché

This image shows what appears on the front end: the [types] shortcode isn't being recognised.

lien caché

(This is the key faulty output:
With Shortcode – wprss_item_date: 01 Jan 1970[/types]]

I've used this construct before and have run out of ideas of what to test...




Hi Alex,

Thank you for contacting us and I'd be happy to assist.

Can you please make sure that the custom shortcode "acur_date_from_time" has been added in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content?

Also, since you need a raw date type custom field value, you can also replace "types" shortcode with the simpler "wpv-post-field" shortcode:
( note that for custom fields added by Types, you'll need to include the prefix "wpcf-" before the field slug )

I hope this helps and please let me know if you need any further assistance around this.



Thanks Waqar

I'd tried registering the shortcode as a third-party argument, even though it wasn't being used to provide an argument. I registered it again anyway just now. I also tried using wpv-post-field instead of the types shortcode. All with no effect.

This is what I get

lien caché

(The field wprss-item-date is provided by another plugin, but I've set it to be "Managed with Types" in the Post Field Control section)

And just now, I deactivated all plugins except Toolset Types, Toolset Blocks and the WP RSS Aggregator plugins - still with no impact (and I cleared caching as well!)



Thanks for the update.

Can you please share temporary admin login details along with the link to the page where I can see these shortcodes?

I'd also like to see the code for the custom shortcode "acur_date_from_time".

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.


Thank you for waiting and I apologize for the delay in getting back on this.

During testing on your staging website, I noticed that the issue is only happening when used inside a reusable block. The same nested shortcode works correctly, if it is directly added to the content template, without a reusable block.

Based on this the following updated code for the custom shortcode, works on my test website, even from inside a reusable block:

function acur_date_from_time_func( $atts, $content = null ) {
	$content = do_shortcode($content);

	if(!empty($content)) {
		$postDate = date('d M Y', intval($content));
		return $postDate;

add_shortcode( 'acur_date_from_time', 'acur_date_from_time_func' );

To use it, you'll need to provide the number or source shortcode as a shortcode's content instead of an attribute, for example:

[acur_date_from_time][wpv-post-field name="wprss_item_date"][/acur_date_from_time]

This should do the trick.



Thanks very much, Waqar.

My issue is resolved now.

Ce ticket est maintenant fermé. Si vous êtes un client de Toolset et que vous avez besoin d'aide, veuillez ouvrir un nouveau ticket d'assistance