MediaPress Like & Unlike button for Photos, Videos, etc. with WP ULike plugin
MediaPress is the most awesome photo gallery plugin for BuddyPress. Simple reason, it is built on a very strong architecture. MediaPress is aimed to make developers enjoy while it can cost-efficient for the site admins. I guess that was enough of the advertisement ๐
Today, In this post, Let me show you if you need a like button for photos, etc., how easy that can be.
Have you heard about the WP Ulike Plugin? Georges pointed me in the comments, It seemed nice to me. He wanted the support of Like with this plugin, so I spent my precious 5 minutes today (Don't be serious, It was not that much precious after all), and here is what I got?
See that like button in the lightbox as well as on single Media page?
Great, now, here is the code that I used.
1 2 3 4 5 6 7 8 9 10 11 12 | //show it on single media page add_action( 'mpp_media_meta', 'mpp_wpulike_show_button' ); //show it in lightbox add_action( 'mpp_lightbox_media_meta', 'mpp_wpulike_show_button' ); function mpp_wpulike_show_button() { if( function_exists( 'wp_ulike_put_posts' ) ) { echo wp_ulike_put_posts(''); } } |
Isn't it nice to have the button in 4-5 lines of code working? Now, you better believe me that MediaPress is fun to work with. If you still don't believe me, I strongly recommend checking the source code. Hopefully, that will make you a ย believer.
If you are using MediaPress and want us to improve it, please do let us know your feedback in the community support forum. We are all ears ๐
Thank you, Brajesh, for this addition. It looks great on the screenshot. Which file did you insert the code in? It doesn't work with bp-custom.php or functions.php (tested with Twenty Fifteen and FirmaSite themes).
Well, the likes are visible on single media pages, if I insert the code in the functions.php of the theme and allow, in the settings of Ulike, to show likes on Pages. I had restricted that because I don't want it to show likes on Pages generally. That affected media pages as well.
The developer of Ulike gives the following function on his wordpress page(faq):
Is it possible to implement this function in the mediapress files so that only media pages be affected?
PS As for the lightbox, there I see nothing, even if I allow Ulike to show likes everywhere.
The code
Hi Georges,
1. Have you upgraded to the latest version of MediaPress from github? The lightbox meta action was not there earlier, so anything older than yesterday will not show it.
To be honest, I did not even configure the ULike(Just activated if I remember correctly) plugin and put that code which worked. Please point me to the code( Or you can post in the forum ) and I will check and update.
Hi again, I tried twice to post the code here but nothing appears. Well you will find the function at this url https://wordpress.org/plugins/wp-ulike/faq/
under the question: How To Use this plugin?
PS I didn't update mediapress. You know, for all of us that don't use english, the translation is a problem. Many strings are not included in the po file and some others that are included are not recognized by mediapress and we must edit directly in the core files. Searching in all those files ttook me a whole day. I did that 5 days before and I don't have the courage to do it again soon. Never mind if that doesn't show likes on lightbox.
One more 'like' plugin which seems to be working with MediaPress https://likebtn.com/en/wordpress-like-button-plugin
Thank you Michael.
It is always good to know. The more the merrier ๐
Hi Brajesh,
Nice work!
The only problem I have with this code is that it places a like button inside the lightbox, but there is a separate like button for the same photo on the activity page. This means that you can like the photo from inside the lightbox, but when you close the lightbox and go back to the activity page, there is a separate like button that has not registered the like.
Is there any way to show the same like button on the activity post as well as inside the lightbox?
Thanks!
Hi Simon,
I am sorry about that. The activity like is handled by the wpulike plugin in core.
I am not sure if we can do that as an activity can have multiple media attached to it. But here is a good news, we have just released the Media rating plugin for MediaPress and next on our list is the media like. That will resolve it ๐