Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * List all Badges based on their badge_type.
- */
- function get_list_types_badges( $type ) {
- global $post;
- $args = array(
- 'order' => 'ASC', // ascending order, 1,2,3 (oldest post first)
- 'post_type' => 'mycred_badge', // search in the post type "mycred_badge"
- 'badge_type' => $type, // only list the badges assigned to the badge type entered
- 'post_status' => 'publish' // only list those who are publish, no drafts
- );
- $myposts = get_posts( $args );
- echo '<ul class="list-badges">';
- foreach ( $myposts as $post ) : setup_postdata( $post );
- echo '<li>';
- echo check_badge_status();
- $img_url = get_post_meta( get_the_ID(), 'main_image', true );
- // myCRED 1.7+ (badge images are no longer connected via a URL but an attachment ID)
- if ( is_numeric( $img_url ) )
- $img_url = wp_get_attachment_url( $img_url );
- // check if the custom field has a value
- if( ! empty( $img_url ) ) {
- echo '<img class="badge_id-'.get_the_ID().'" src="'.$img_url.'" alt="'.get_the_title().'" />';
- }
- echo '</div>';
- echo '<h5>'.get_the_title().'</h5>';
- echo '<span>( ' .mycred_count_users_with_badge( get_the_ID() );
- echo ' / ';
- echo count_all_my_users(). ' )</span>';
- echo '</li>';
- endforeach;
- echo '</ul>';
- wp_reset_postdata();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement