Problem:
have a custom archive type and I'm adapting it. I wanted the article layout to match the theme and I managed to do that.
However, I'm having a problem with the "heart" (like) under each article.
The "heart" comes "red" when I like the post post, as it should. However, if I refresh the page it reverts to "unliked" mode - white heart. I have attached a screenshot of it.
I have this html code in the page which I have copied from the theme and just adding the custom elements that I needed.
Solution:
It needs some custom PHP codes, for example you can try these:
1) Add below codes into your theme/functions.php:
function user_liked_post(){ $post_id = get_the_ID(); $res = penci_AlreadyLiked( $post_id ); return $res; }
2) Dashboard-> Toolset-> Settings-> Front-end Content
option "Functions inside conditional evaluations", fill above custom PHP function name: user_liked_post
3) Edit the wordpress archive "Categories, Tags": ID 1787
Edit this line from:
<a class="penci-post-like" ...
To:
<a class="penci-post-like [wpv-conditional if="user_liked_post()"]liked[/wpv-conditional]" ...
Relevant Documentation:
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Hong_Kong (GMT+08:00)
This topic contains 16 replies, has 2 voices.
Last updated by 6 years, 10 months ago.
Assisted by: Luo Yang.