Count number of published posts by type

If you prefer the $wpdb direct queries you can use something like this:

global $wpdb;   
$count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_type="code" and post_status="publish"" );
echo $count;

In the sql query above change the post_type to whatever you like. This will return count of published posts under specific post type only.

If you want to query counts from multiple post types do this query:

global $wpdb;   
$count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_type IN ( 'code', 'shop', 'post', 'etc' ) and post_status="publish"" );
echo $count;

Hope that helps.