Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_shortcode( 'products-counter', 'products_counter_shortcode' );
- function products_counter_shortcode( $atts ) {
- $atts = shortcode_atts( [
- 'author' => '',
- ], $atts );
- $the_user = get_user_by('login', $atts['author']);
- $userid = $the_user->ID;
- return 'Broj objavljenih proizvoda: ' . $atts['author'] . ' ' . count_user_posts($userid, 'product', true);
- }
- /* shortcode usage [products-counter author="username1"]
Add Comment
Please, Sign In to add comment