Skip to main content

You can try this code.

global $wpdb;
$meta_key = 'link_click_counter';
$all_downloads = $wpdb->get_var($wpdb->prepare("
                                  SELECT sum(meta_value) 
                                  FROM $wpdb->postmeta 
                                  WHERE meta_key = %s", $meta_key));

<?php echo $all_downloads; ?>

You can try this code.

$meta_key = 'link_click_counter';
$all_downloads = $wpdb->get_var($wpdb->prepare("
                                  SELECT sum(meta_value) 
                                  FROM $wpdb->postmeta 
                                  WHERE meta_key = %s", $meta_key));

<?php echo $all_downloads; ?>

You can try this code.

global $wpdb;
$meta_key = 'link_click_counter';
$all_downloads = $wpdb->get_var($wpdb->prepare("
                                  SELECT sum(meta_value) 
                                  FROM $wpdb->postmeta 
                                  WHERE meta_key = %s", $meta_key));

echo $all_downloads;
Source Link
user113667
user113667

You can try this code.

$meta_key = 'link_click_counter';
$all_downloads = $wpdb->get_var($wpdb->prepare("
                                  SELECT sum(meta_value) 
                                  FROM $wpdb->postmeta 
                                  WHERE meta_key = %s", $meta_key));

<?php echo $all_downloads; ?>