Closing shortcode in WordPress -
i made simple wordpress plugin highlights text.
add_shortcode('close-span', 'highlighter_closing_span_shortcode'); function highlighter_closing_span_shortcode($atts) { return '</span>'; }
it's closing shortcode part of plugin. in case, users must type "[close-span]". want change "[/span]". how can modify code above?
you can use $content
parameter of shortcode allow users put copy between tags:
add_shortcode( 'span', 'my_span_shortcode' ); function my_span_shortcode( $atts, $content = null ){ return '<span class="highlighted">' . $content . '</span>'; }
you use shortcode this:
[span]this highlighted[/span]
and result in:
<span class="highlighted">this highlighted</span>
Comments
Post a Comment