Answer the question
In order to leave comments, you need to log in
How to send sql query using PHP?
Dear programmers, tell me, please!
There is a food blog on WordPress. Installed plugin Yet Another Stars Rating. I want to pull out the digital values of the rating of records in order to add microdata. There are plans to remove the micro-markup of the plugin. Why? The Blog has already set up its own markup of recipes through functions and meta tags. After installation of a plug-in in a DB there was a trace.
wp_yasr_log table
The following 2 queries in the database give the desired values
SELECT AVG(`vote`) FROM wp_yasr_log WHERE `post_id` = 53
SELECT COUNT(`vote`) FROM wp_yasr_log WHERE `post_id` = 53
53 - record ID, must be current.
How to correctly execute these queries in the DB and get the values (quantitative) inside the template
Tried that, didn't get anything. More precisely, I get 0.
<?php
global $wpdb;
$post_id_num = get_the_ID();
$rating_count = intval(
$wpdb->get_var( "SELECT COUNT(`vote`) FROM $wpdb->yasr_log WHERE `post_id` = $post_id_num"
));
?>
<meta itemprop="ratingCount" content="<?php echo $rating_count; ?>">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question