llms_get_object_total_favorites( bool|int $object_id = false )
Get Favorites Count.
Parameters Parameters
- $object_id
-
(bool|int) (Optional) WP Post ID of the Lesson. If not supplied it will default to the current post ID.
Default value: false
Return Return
(int)
Source Source
File: includes/functions/llms.functions.favorite.php
function llms_get_object_total_favorites( $object_id = false ) {
global $wpdb;
// Getting ID from Global Post object.
if ( ! $object_id ) {
$object_id = get_the_ID();
}
$res = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(DISTINCT meta_id) FROM {$wpdb->prefix}lifterlms_user_postmeta
WHERE post_id = %d AND meta_key = %s ORDER BY updated_date DESC",
$object_id,
'_favorite'
)
); // db call ok; no-cache ok.
return $res;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 7.5.0 | Introduced. |