Created
June 22, 2021 07:45
-
-
Save Alimir/dac482e726ced8c77d230d8327804e7e to your computer and use it in GitHub Desktop.
Get number of likes received by post author
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
<?php | |
function wp_ulike_custom_author_counter( $user_id, $status = 'like' ){ | |
global $wpdb; | |
$meta_key = wp_ulike_setting_repo::isDistinct( 'post' ) ? 'count_distinct_' . $status : 'count_total_' . $status; | |
return $wpdb->get_var( | |
$wpdb->prepare( | |
"SELECT SUM(m.meta_value) FROM {$wpdb->prefix}ulike_meta m INNER JOIN $wpdb->posts p ON m.item_id = p.ID AND p.post_author = %s WHERE m.meta_group = 'post' AND m.meta_key = %s", | |
$user_id, | |
$meta_key | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment