Shortcode wordpress

Définition de base

[monShortcode]

définition de base

// Add Shortcode
function custom_shortcode() {
}
add_shortcode( '', 'custom_shortcode' );

exemple avec paramètres

[video_embed src=”” width=”” height=””]

// Add Shortcode
function video_embed_shortcode( $atts ) {

	// Attributes
	extract( shortcode_atts(
		array(
			'src' => '',
			'width' => '',
			'height' => '',
		), $atts )
	);

	// Code
return '<embed 
		src="' . $src . '"
		width="' . $width . '"
		height="' . $height . '"
		type="application/x-shockwave-flash"
		allowscriptaccess="always"
		allowfullscreen="true">';

}
add_shortcode( 'video_embed', 'video_embed_shortcode' );

Codex wordpress

informations complémentaires:

Leave a Reply

Your email address will not be published. Required fields are marked *


8 × = huit

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>