Simple Shortcode

WPTurbo » Snippets » Simple Shortcode
0

Created with:

Shortcode Generator

Visibility: 

public

Creator: Ulrik Vander

Customize with WPTurbo AI
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' );

			

Register an account to save your snippets or go Pro to get more features.