add_shortcode('숏코드이름', '콜백함수');add_action( 'init', 'rdg_shortcode' );
function rdg_shortcode() {
add_shortcode( 'footag', 'rdg_callback_func' );
}
function rdg_callback_func(){
return "정상작동";
}일반적으로 권장하는 사용방법입니다.
add_shortcode( 'bartag', 'wpdocs_bartag_func' );
function wpdocs_bartag_func( $atts ) {
$atts = shortcode_atts( array(
'foo' => 'no foo',
'baz' => 'default baz'
), $atts, 'bartag' );
return "foo = {$atts['foo']}";
}add_shortcode( 'baztag', 'wpdocs_baztag_func' );
function wpdocs_baztag_func( $atts, $content = "" ) {
return "content = $content";
}[baztag]content[/baztag] 의 경우는 다음과 작성할 수 있습니다.
shortcode_exists()숏코드가 있는지 확인하려면 shortcode_exists() 함수를 사용해보세요.
remove_shortcode(
string $tag
);숏코드를 강제로 삭제하는 방법이 있습니다