admin管理员组文章数量:1426041
add_shortcode( 'show-the-views', function( ) {
);
$count = get_post_meta( get_the_ID(), 'views', true );
return $count . ' views';
});
This code is working but I have to add a placeholder in the shortcode for example [doc_wp_live_search placeholder="Have a question?"]. Currently, it is showing views. But I want to give an option for the user.
add_shortcode( 'show-the-views', function( ) {
);
$count = get_post_meta( get_the_ID(), 'views', true );
return $count . ' views';
});
This code is working but I have to add a placeholder in the shortcode for example [doc_wp_live_search placeholder="Have a question?"]. Currently, it is showing views. But I want to give an option for the user.
Share Improve this question edited May 27, 2019 at 11:35 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked May 27, 2019 at 10:34 AnkushAnkush 33 bronze badges1 Answer
Reset to default 0function show_the_views_func( $atts ){
$atts = shortcode_atts(
array(
'placeholder' => '',
), $atts
);
$count = get_post_meta( get_the_ID(), 'views', true );
return $count . $atts['placeholder'] . ' views';
}
add_shortcode( 'show-the-views', 'show_the_views_func' );
echo do_shortcode( '[show-the-views placeholder="test"]' );
本文标签: How I can add placeholder in shortcode
版权声明:本文标题:How I can add placeholder in shortcode 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745460401a2659298.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论