0

I'm using jet-pack carousel in my gallery website and i want to add image rating capabilities. I have the "wp-postratings" plugin running on the rest of my site.

I'm assuming that i could add this to individual images as wp treats each image as a post, if so where would i find the template i should add this code to?

All the plugin requires is that i add one line of php to the page/image but i can't figure out where it shoud go as the code for carousel seems to be entirely js and php generated.

SpeedCrazy
  • 505
  • 2
  • 7
  • 19

2 Answers2

2

in a js file jetPack_meet_wpPostRating.js copy this code (place the file in the js folder of your theme):

in the functions.php file of your theme put this code:


  • NOTE
  • after installing the above scripts make sure to delete the browser cache before test.
  • tested with latest wordpress, jetpack and wp-postrating versions.
  • this will also work with multiple gallery in the same page.
  • does not need to put any extra [ratings] shortcode anyware.
  • the bounty for this answer is too low... ;)

  • FIX
  • Fixed bugs added some check and debug to consol.log...
Luca Filosofi
  • 30,905
  • 9
  • 70
  • 77
  • I'm afraid it doesn't work. I'm wondering if that is because of my eazyest gallery plugin. All that this code has changed is that thumbnails have their titles over them at all times instead of just when the mouse is put over them. Thanks though. – SpeedCrazy Mar 23 '14 at 00:01
  • @SpeedCrazy i don't know the eazyest gallery plugin, anyway i'm preparing a live demo for you. as i said i have coded it on a fresh wp install with jetpack and wp-postratings plugin as you described in the question. – Luca Filosofi Mar 23 '14 at 18:27
  • Thanks for the update, I will test it ASAP when i get home tomorrow. – SpeedCrazy Mar 25 '14 at 23:20
  • @SpeedCrazy: i have updated it a little bit the js part, causei found a little bug... pls update with latest code on github... – Luca Filosofi Mar 26 '14 at 15:22
  • I appreciate all your hard work man, and i'd increase the bounty if i could, but it still doens't work. IT now throws an internal server error whenever i include your code. I don't have the time to sit and debug it line by line, but i was wondering if it had something to do with when it is loaded? My theme has a file for custom php that it loads last from a different directory where i placed this. Note i tried placing it in the file directly but that failed as well. – SpeedCrazy Mar 28 '14 at 00:05
  • I'm installing a fresh wp copy in another dir and will test in there tomorrow. If that works i will assume on of my plugins is making a mess of your code and work from there. – SpeedCrazy Mar 28 '14 at 00:30
  • i have not enough information to help you (what theme do you have?)... btw i have updated the the code again (see the gist) changing the only thing i guess can be responsible of that error. i changed the global variable $id to $post – Luca Filosofi Mar 28 '14 at 10:07
  • I have photoria, but when i deactivate the plugins i will switch to the default theme. Will check the changed code ASAP. – SpeedCrazy Mar 28 '14 at 14:11
  • @SpeedCrazy: tested photoria and it work. problem is not the theme. – Luca Filosofi Mar 28 '14 at 15:01
  • Okay. I'm deactivating my plugins as we speak will test your code again in a sec. – SpeedCrazy Mar 28 '14 at 16:17
  • Well i did something and broke my site. I appreciate all your help and I'm going to mark this as answered because i'm sure it will work perfectly on a fresh install. The break wasn't related to your plugin thoug :) Thanks a million man. – SpeedCrazy Mar 29 '14 at 21:57
  • @SpeedCrazy: if i can help any way just let me know. – Luca Filosofi Mar 30 '14 at 10:35
0
You can use hook into the Jetpack Carousel on the server-side 
(like to output your data, for example). 

Then on the client-side, get your Javascript rating code to 
load after the Jetpack+Carousel JS, and hook into them 
(hook on the bindings, etc). 

 JetPack provides 2 JavaScript hooks: 
 1) jp_carousel.afterOpen 
 2)jp_carousel.beforeClose. 

Action hook code example

Ravi Patel
  • 5,121
  • 2
  • 25
  • 44