Add rating to post plugin
-
Hello,
I wish to add overall rating to the post of masonry layout plugin.
I want to put it instead of this:
<?php if ($layoutSettings['show_post_meta'] == 'yes'): ?> <div class="wmle_post_meta"> <a href="<?php comments_link(); ?>"><?php comments_number('0 Response', '1 Response', '% Responses' ); ?></a> </div> <?php endif; ?>
I want to add it instead of this code, where should I put [yasr_overall_rating size=”small”] or it should be somehow different?
You can see what I have in mind here: https://atrasklietuva.lt/2/wordpress/pinterest/
-
Try, inside the div, to remove that line and paste this
<?php echo do_shortcode( '[yasr_overall_rating size="small"]' ); ?>
It partly works! It shows my text but not the stars of the rating. Maybe I should add something to the styles.php too or change the div class name?
maybe it is better to put PHP code of the rating? What is it? Not the shortcode but the php code to get the rating for the post?
One thing to note here is that I’m seeing these errors in the error_log ( after installing the plugin )
WordPress database error Table 'mydb.wp_yasr_log' doesn't exist for query SELECT * FROM wp_yasr_log ORDER BY date DESC LIMIT 0, 8 made by wp_dashboard, do_meta_boxes, call_user_func, yasr_display_dashboard_log_wiget
I’ve tried uninstalling this plugin and re-installing it, deleting it, etc.
Seems like the installer is fubar’ed or something…
Edit: Just to be clear, the above is not the only error. Any attempt to access a MySQL table that is for YASR throws an error. I checked my wp database and there are 0 tables for YASR installed. Other plugins install just fine. I’ve tried this on 2 sites so far and same issue. Feels like this is a minor bug. Haven’t looked further into it yet.
Point is: try checking your own error logs ( /var/log/nginx/error.log or /var/log/yourwebserverhere/error.log or even your php error log) – see if you’re having the same issues. if you are, chances are you aren’t doing anything wrong.
Just creating another post here instead of adding on to the above:
Installing YASR works, and then activating it works. I can call
echo do_shortcode( '[yasr_visitor_votes size="small"]' );
to place it on any page which does work as well – the stars system shows.However, if you try to rate a post ( either on the frontend or the backend ( while on a post page ) ) the errors reported above in my previous comment flood the error log.
Example output ( with my real db being replaced with
mydb
and the path to wp being replaced with/path/to/
) is as follows:[06-Oct-2014 20:34:06 UTC] WordPress database error Table 'mydb.wp_yasr_log' doesn't exist for query SELECT * FROM wp_yasr_log ORDER BY date DESC LIMIT 0, 8 made by wp_dashboard, do_meta_boxes, call_user_func, yasr_display_dashboard_log_wiget [06-Oct-2014 20:36:32 UTC] WordPress database error Table 'mydb.wp_yasr_log' doesn't exist for query SELECT * FROM wp_yasr_log ORDER BY date DESC LIMIT 0, 8 made by wp_dashboard, do_meta_boxes, call_user_func, yasr_display_dashboard_log_wiget [06-Oct-2014 20:37:06 UTC] WordPress database error Table 'mydb.wp_yasr_multi_set' doesn't exist for query SELECT * FROM wp_yasr_multi_set ORDER BY set_id ASC made by include('wp-admin/edit-form-advanced.php'), do_action('add_meta_boxes'), call_user_func_array, yasr_add_metaboxes, yasr_get_multi_set [06-Oct-2014 20:37:06 UTC] WordPress database error Table 'mydb.wp_yasr_votes' doesn't exist for query SELECT overall_rating FROM wp_yasr_votes WHERE post_id=422 made by include('wp-admin/edit-form-advanced.php'), do_meta_boxes, call_user_func, yasr_metabox_overall_rating_content, include('/path/to/wp-content/plugins/yet-another-stars-rating/yasr-metabox-overall-rating.php'), yasr_get_overall_rating [06-Oct-2014 20:37:06 UTC] WordPress database error Table 'mydb.wp_yasr_votes' doesn't exist for query SELECT review_type FROM wp_yasr_votes WHERE post_id=422 made by include('wp-admin/edit-form-advanced.php'), do_meta_boxes, call_user_func, yasr_metabox_overall_rating_content, include('/path/to/wp-content/plugins/yet-another-stars-rating/yasr-metabox-overall-rating.php'), yasr_get_snippet_type [06-Oct-2014 20:37:08 UTC] WordPress database error Table 'mydb.wp_yasr_votes' doesn't exist for query UPDATE <code>wp_yasr_votes</code> SET <code>overall_rating</code> = '4.5', <code>reviewer_id</code> = 2 WHERE <code>post_id</code> = 422 made by do_action('wp_ajax_yasr_send_overall_rating'), call_user_func_array, yasr_insert_overall_rating_callback [06-Oct-2014 20:37:08 UTC] WordPress database error Table 'mydb.wp_yasr_votes' doesn't exist for query REPLACE INTO <code>wp_yasr_votes</code> (<code>post_id</code>,<code>overall_rating</code>,<code>reviewer_id</code>,<code>review_type</code>) VALUES (422,'4.5',2,'Product') made by do_action('wp_ajax_yasr_send_overall_rating'), call_user_func_array, yasr_insert_overall_rating_callback [06-Oct-2014 20:37:08 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 for query SELECT review_type FROM wp_yasr_votes WHERE post_id= made by do_action('wp_ajax_yasr_send_overall_rating'), call_user_func_array, yasr_insert_overall_rating_callback, yasr_get_snippet_type [06-Oct-2014 20:37:08 UTC] WordPress database error Table 'mydb.wp_yasr_votes' doesn't exist for query UPDATE <code>wp_yasr_votes</code> SET <code>review_type</code> = 'Product' WHERE <code>0</code> = '%s' made by do_action('wp_ajax_yasr_send_overall_rating'), call_user_func_array, yasr_insert_overall_rating_callback [06-Oct-2014 20:37:10 UTC] WordPress database error Table 'mydb.wp_yasr_votes' doesn't exist for query UPDATE <code>wp_yasr_votes</code> SET <code>review_type</code> = 'Product' WHERE <code>post_id</code> = 422 made by do_action('wp_ajax_yasr_insert_review_type'), call_user_func_array, yasr_insert_review_type_callback [06-Oct-2014 20:37:10 UTC] WordPress database error Table 'mydb.wp_yasr_votes' doesn't exist for query REPLACE INTO <code>wp_yasr_votes</code> (<code>post_id</code>,<code>overall_rating</code>,<code>review_type</code>) VALUES ('422','-1','Product') made by do_action('wp_ajax_yasr_insert_review_type'), call_user_func_array, yasr_insert_review_type_callback [06-Oct-2014 20:37:23 UTC] WordPress database error Table 'mydb.wp_yasr_votes' doesn't exist for query UPDATE <code>wp_yasr_votes</code> SET <code>review_type</code> = 'Product' WHERE <code>post_id</code> = 422 made by do_action('wp_ajax_yasr_insert_review_type'), call_user_func_array, yasr_insert_review_type_callback [06-Oct-2014 20:37:23 UTC] WordPress database error Table 'mydb.wp_yasr_votes' doesn't exist for query REPLACE INTO <code>wp_yasr_votes</code> (<code>post_id</code>,<code>overall_rating</code>,<code>review_type</code>) VALUES ('422','-1','Product') made by do_action('wp_ajax_yasr_insert_review_type'), call_user_func_array, yasr_insert_review_type_callback [06-Oct-2014 20:37:32 UTC] WordPress database error Table 'mydb.wp_yasr_votes' doesn't exist for query UPDATE <code>wp_yasr_votes</code> SET <code>review_type</code> = 'Product' WHERE <code>post_id</code> = 422 made by do_action('wp_ajax_yasr_insert_review_type'), call_user_func_array, yasr_insert_review_type_callback [06-Oct-2014 20:37:32 UTC] WordPress database error Table 'mydb.wp_yasr_votes' doesn't exist for query REPLACE INTO <code>wp_yasr_votes</code> (<code>post_id</code>,<code>overall_rating</code>,<code>review_type</code>) VALUES ('422','-1','Product') made by do_action('wp_ajax_yasr_insert_review_type'), call_user_func_array, yasr_insert_review_type_callback
@ Okiro: if doesn’t work with that code, it will not work. Yasr was made to work only in post page or archive page
@infolock: first of all the [yasr_visitor_votes] work only in single post or page, it doesn’t work on archive page.
Seems like yasr hasn’t built the tables: what I want to know is this: what is the prefix of your wordpress tables? From the log seems mydb.wp_ but this is really strange; default wordpress installation use wp_ : have you added the prefix mydb. ?
@ Okiro: if doesn’t work with that code, it will not work. Yasr was made to work only in post page or archive page
So it is not possible? Any shortcuts/ideas how to do so? I don’t want to look for another plugin… I like yours and support too!
I’m so sorry but I can’t integrate YASR with every plugin out there. ??
Best,
DarioDear do you have any idea if it is compatible with wp estore as it seems to be not working. It is breaking the product box. Seems some CSS issues.
@srmanuals: no, can you post a link with the breaked product box?
@dudo “first of all the [yasr_visitor_votes] work only in single post or page, it doesn’t work on archive page.” <<<— Yep, I understand that
“Seems like yasr hasn’t built the tables” <<<—- Yep, that’s what I was saying in my comments above
“what is the prefix of your wordpress tables?” <<<—– “wp_” is the prefix I’m using
“From the log seems mydb.wp_ but this is really strange;” <<<—- why? mydb is just the name of my database – has nothing to do with wordpress
“default wordpress installation use wp_” <<<—- yes, that’s correct.
“have you added the prefix mydb. ?” <<<—- mydb isn’t a prefix – its the name of my databvase
Ok, I can just suggest to unistall yasr, remove all the tables that begin with wp_yasr and then do what I suggested here
After this, try to install it again. It should workThanks I’ll try what you’re suggesting (I’ve done what you’re suggesting but not since the latest updates after this thread as opened). If same issues, I’ll follow up with a new ticket.
- The topic ‘Add rating to post plugin’ is closed to new replies.