Last active
August 16, 2017 19:13
-
-
Save JarrydLong/d48ac419623490115130fc9f155e344b to your computer and use it in GitHub Desktop.
Show total markers for a specific map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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