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"]' );
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745460402a4628682.html
评论列表(0条)