'; // if visitor ins't logged_in add this
}
}
/**
* 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 '
';
foreach ( $myposts as $post ) : setup_postdata( $post );
echo '- ';
echo check_badge_status();
$img_url = get_post_meta( get_the_ID(), 'main_image', true );
echo '
'.get_the_title().'
';
// check if the custom field has a value
if( ! empty( $img_url ) ) {
echo '';
}
echo '
';
echo '';
endforeach;
echo '';
wp_reset_postdata();
}
/**
* myCRED Shortcode: mycred_list_badges
* @since 1.5.3
* @version 1.5.3
*/
// [mycred_list_badges type="posting"]
function mycred_list_badges( $atts ){
extract( shortcode_atts( array(
'type' => 'general',
), $atts ) );
ob_start();
get_list_types_badges($type);
$output = ob_get_contents();
ob_end_clean();
return $output;
}
add_shortcode( 'mycred_list_badges', 'mycred_list_badges' );