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?
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/
Well yes, that is another possibility 🙂