0
X
Add Snippet To Project
New Project
Add To Existing Project
/**
* Registers a custom shortcode called 'shortcode-name'
*
* @since 1.0.0
*
* @param array $atts Shortcode attributes user entered.
* @return string The shortcode output.
*/
function wpturbo_my_shortcode_function( $atts ) : string {
$atts = shortcode_atts([
'rest_url' => '',
'category' => '',
'Sidebar' => true,
], $atts);
$atts['rest_url'] = (string) $atts['rest_url'];
$atts['category'] = (string) $atts['category'];
$atts['Sidebar'] = (bool) $atts['Sidebar'];
return '';
}
add_shortcode( 'shortcode-name', 'wpturbo_my_shortcode_function' );