Skip to content

Instantly share code, notes, and snippets.

@JarrydLong
Last active August 16, 2017 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JarrydLong/d48ac419623490115130fc9f155e344b to your computer and use it in GitHub Desktop.
Save JarrydLong/d48ac419623490115130fc9f155e344b to your computer and use it in GitHub Desktop.
Show total markers for a specific map
add_shortcode( 'wpgmza_total_markers', 'wpgmza_total_marker_count' );
function wpgmza_total_marker_count( $atts ){
$atts = shortcode_atts( array(
'id' => 1,
), $atts, 'wpgmza_total_markers' );
$map_id = intval( $atts['id'] );
global $wpdb;
$table_name = $wpdb->prefix.'wpgmza';
$sql = "SELECT count(*) as total_markers FROM `$table_name` WHERE `map_id` = '$map_id'";
$total_count = $wpdb->get_row( $sql );
if( $total_count ){
return $total_count->total_markers;
} else {
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment