functions.php ファイルに次のコードがあります。私がやりたいことは、ショートコード [テンプレート] にもう 1 つの属性 (「extraclass」としましょう) を追加することです。属性の値は追加のクラスの名前である必要があり、コードでこのクラスを body タグに追加する必要があります。add_filter 関数について知っています。使用しようとしましたが、成功しませんでした。
function templatefn($atts, $content = null) {
extract(shortcode_atts(array(
"content" => ""
), $atts));
ob_start();
get_template_part('content', $content);
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
add_shortcode('template', 'templatefn');
前もって感謝します!