- This topic has 25 replies, 3 voices, and was last updated 4 years, 8 months ago by David.
-
AuthorPosts
-
August 8, 2019 at 4:04 am #978844Charalambos
Hello,
I have an issue with a plugin and i was hoping you help me sort it out.
I have installed a review plugin that allows you to show the overall rating at homepage and archives as a thumb in the top right featured picture of the post. Here is their demo page below where you can see how it looks,
https://demos.codetipi.com/letsreview
However, as I found out after buying the plugin, to achieve this you need some extra customization. Here is the message I received from the plugin developer,
“Regarding the posts on the homepage, it’s literally impossible for a plugin to inject content of this type into the archives loop of a theme, as every theme is coded differently. Most won’t even have a way to inject into that location (next to the featured image in the posts loop).
You will need to ask the maker of your theme for the correct way to inject post meta data into the archives post loop. If you show them the documentation below, they’ll definitely understand what needs to be done and will be able to advise you.”
https://docs.codetipi.com/lets-review/#api
Could you please advise if this is possible to be done with Generate press, and if yes how can i do it?
regards
Pambos
August 8, 2019 at 5:57 am #978935DavidStaffCustomer SupportHi there,
you could try this:
1. Create a new Hook Element
2. Add this for the content:<?php global $post; if ( class_exists( 'Lets_Review_API' ) ) { $my_score_box = Lets_Review_API::lets_review_get_score_box( $post->id ); echo $my_score_box; } else { // do nothing } ?>
3. Select the
before_entry_title
hook
4. Check Execute PHP
5. Set the Display rules to Blog and Archives.Let me know if the content displays i can then take a look at the CSS required for positioning.
August 8, 2019 at 6:25 am #978945CharalambosHello David,
Just tried this, but it doesn’t work i m afraid
August 8, 2019 at 7:04 am #978973DavidStaffCustomer SupportI made slight change to the code above, can you try that and let me know.
August 8, 2019 at 7:54 am #979123CharalambosI tried this as well, but nothing changes.
August 8, 2019 at 9:20 am #979193TomLead DeveloperLead DeveloperI wonder if the condition is working.
Can you try this?:
<?php global $post; if ( class_exists( 'Lets_Review_API' ) ) { $my_score_box = Lets_Review_API::lets_review_get_score_box( $post->id ); echo $my_score_box; echo 'hi'; } else { // do nothing } ?>
Does the word “hi” appear?
August 8, 2019 at 9:44 am #979220CharalambosHello Tom,
Yes it appears below the featured image.
August 8, 2019 at 4:46 pm #979428TomLead DeveloperLead DeveloperSo that means
$my_score_box
isn’t working properly.It might be worth asking their support if we’re using the function correctly. I can’t see why it wouldn’t be working, but I’m not familiar with their plugin, unfortunately.
August 9, 2019 at 4:14 am #979714CharalambosHello Tom,
Ok, I have send the plugin developer a message linking to this post, so he can have a look at the code we are using.
Also I don’t know what exactly does he mean or if this helps, but going through the plugin’s support comments, he seems to insist that the function must be inside the loop and also the the api code needs to be inserted wherever the theme outputs the post data.August 9, 2019 at 4:29 am #979732DavidStaffCustomer SupportDo you have the API Code that needs to be inserted?
August 9, 2019 at 5:13 am #979758CharalambosHi,
But I think you have already used it in your first reply to this post. Here it is again,
August 9, 2019 at 5:16 am #979759DavidStaffCustomer SupportWas checking to see if there was any other code the plugin author supplied. Best check with them to see whats missing.
August 9, 2019 at 5:54 am #979773CharalambosHello,
I have been searching his support comment forum and found an answer he gave with some other codes. Again I don’t know if this helps, but I copy his answer below,
For anyone else wondering, there is an easier way to get the scores data via the plugin’s API, you probably need a bit of developing knowledge (or if you can reverse-engineer it all) you could use this instead:
First you need to be inside a loop (the code of whatever “blog style” generates your lists of post is a loop), you could get the scores using this:
if ( class_exists( ‘Lets_Review_API’ ) ) {
$lets_review_api = new Lets_Review_API();
if ( $lets_review_api->lets_review_get_onoff( $post->ID ) == false ) { return; }
$final_score = $lets_review_api->lets_review_get_final_score( $post->ID );
$color = $lets_review_api->lets_review_get_color( $post->ID );
// Output the variables here depending on how your theme is outputting each post in your blog style
}And now you have the final score assigned to ”$final_score” and the color (in case you want to use that outside of the post too) in a variable called ”$color”.
August 9, 2019 at 6:05 am #979787DavidStaffCustomer SupportAdd this code to the hook instead:
<?php global $post; if ( class_exists( 'Lets_Review_API' ) ) { $lets_review_api = new Lets_Review_API(); if ( $lets_review_api->lets_review_get_onoff( $post->ID ) == false ) { return; } $final_score = $lets_review_api->lets_review_get_final_score( $post->ID ); $color = $lets_review_api->lets_review_get_color( $post->ID ); // Output the variables here depending on how your theme is outputting each post in your blog style echo $final_score; } else { // do nothing } ?>
August 9, 2019 at 7:44 am #979870CharalambosJust to clarify. I should delete the previous code added in the hook and replace with this one. Also shall i change something where it says,
// Output the variables here depending on how your theme is outputting each post in your blog style -
AuthorPosts
- You must be logged in to reply to this topic.