harumemo

メモ書きです。

WordPressのショートコードの作り方(変数と初期値つき)

/* ----------------------------------------
ショートコード「sample-event」
---------------------------------------- */
function shortcode_sample_event_function($atts) {
extract(shortcode_atts(array(
'name' => '',
), $atts));
return 'onclick="_gaq.push([\'_trackEvent\', \'internal\', \'doc\', \'' . $name . '\']);"';
}
add_shortcode('sample-event', 'shortcode_sample_event_function');