Skip Navigation

[Gelöst] Using types shortcode to provide a value to another shortcode – not working

This support ticket is created vor 2 Jahre, 10 Monate. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

This topic contains 5 Antworten, has 2 Stimmen.

Last updated by alexG-4 vor 2 Jahre, 10 Monate.

Assisted by: Waqar.

Author
Artikel
#2089827

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.

hidden link

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

hidden link

(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...

Thanks

Alex

#2090133

Waqar
Supporter

Languages: Englisch (English )

Timezone: Asia/Karachi (GMT+05:00)

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:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-field
( 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.

regards,
Waqar

#2090203

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

hidden link

(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!)

Alex

#2090503

Waqar
Supporter

Languages: Englisch (English )

Timezone: Asia/Karachi (GMT+05:00)

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.

#2092477

Waqar
Supporter

Languages: Englisch (English )

Timezone: Asia/Karachi (GMT+05:00)

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.

#2093285

Perfect!

Thanks very much, Waqar.

My issue is resolved now.

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