Skip Navigation

[Gelöst] Custom output renderer

This support ticket is created vor 6 Jahren, 3 Monaten. 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von svenG vor 6 Jahren, 2 Monaten.

Assistiert von: Nigel.

Author
Artikel
#1108148

Hi,

I am wondering if it is possible to use this shortcode:

[types field="kompatible-betriebssysteme"][/types]

together with a custom php renderer function? I am thinking on something like this:

[types field="kompatible-betriebssysteme" output="\My\Psr\Classname::function"][/types]
[types field="kompatible-betriebssysteme" output="myCustomFunction"][/types]

Or is there another way to be able to get the values in a custom function and then output it?

#1108252

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Hi Sven

I think you want a custom shortcode.

Pass the field name as a shortcode attribute, then in the shortcode get the field value for the current post (the global $post object), then do whatever you want with that value and return it as a string.

My boilerplate code for custom shortcodes looks like this:

add_shortcode( 'shortcode-name', function( $atts = [], $content = null ){

	// provide defaults
	$atts = shortcode_atts( 
		array(
			'field'		=>	'default-value'
		), 
		$atts 
	);

	$output = '';

	// Do stuff

	// Return something
	return $output;
});

You can read more about shortcodes here: https://developer.wordpress.org/plugins/shortcodes/

#1110507

Well yes, that is another possibility 🙂