I have a custom function to count downloaded times for a specific file attached in the post, but i want to display the count of whole post in my website
post meta = download_times
and how to skip time out error message ?
Thank You @prosti for your answer I made Thise small code based on your answer and it works for me
global $post;
$query_args = array(
'post_type' => 'post',
'post_status' => 'publish',
'order' => 'DESC',
'posts_per_page' => -1,
'cat' => 1,
// 'fields' => 'SUM(amount_to_paid)',
);
$sum = 0;
$query = new WP_Query($query_args);
if ( $query->have_posts() ) {
while( $query->have_posts() ) {
$query->the_post();
// do the processing for each post
$sum = $sum + intval(get_post_meta(get_the_id(),'download_counter' ));
}
}
echo $sum ;
I have a custom function to count downloaded times for a specific file attached in the post
- Is this function working?