【发布时间】:2019-10-24 16:18:51
【问题描述】:
我创建了以下短代码来显示块引用:
// Add Shortcode
function quote_shortcode( $atts , $content = null ) {
// Attributes
$atts = shortcode_atts(
array(
'author' => 'author',
'author_job' => 'author_job',
),
$atts
);
return
'<div data-module="expert_quote"><blockquote class="full no-picture"><p>“' . $content . '”</p><footer class="quote-footer"><cite><span class="name">' . esc_attr($atts['author']) . '</span> <span class="title">' . esc_attr($atts['author_job']) . '</span></cite></footer></blockquote></div>';
}
add_shortcode( 'quote', 'quote_shortcode' );
我不想回来
<span class="name">' . esc_attr($atts['author']) . '</span>
如果author 未在短代码中设置。 author_job 也是如此。
我怎样才能做到这一点?
【问题讨论】: