• Resolved bufus

    (@bufus)


    Regarding the snippet posted here, meant to display the rating on homepage listings, and considering I’m a very poor excuse for a newbie coder, I must ask for help implementing it.

    My original intention was to place the rating over the featured image, on the lower right corner. I think it would look awesome, but I can’t achieve that, too dum :/ (I’m using the Customizr theme, if anyone can give me a pointer, I’d appreciate it).

    That being impossible, I thought I’d make a shortcode to show the rating anywhere I’d like inside the content, and if that worked, I’d go for a better approach (one step at a time: first a shortcode, then an action hook, and then failure xD).
    This is what my shortcode looks like:

    add_shortcode('rating', 'wppr_rating');
    function wppr_rating(){
        $output = '';
        // get the ID of the post as $post_id
        $review = new WPPR_Review_Model(get_the_ID());
        $rating = $review->get_rating();
        // display the rating icon or use $rating to display a custom icon
        $output .= 'placeholder text ' . wppr_layout_get_rating( $review, 'donut', 'default', array( 'review-wu-grade' ) );
        return $output;
    }

    Good news, the shortcode works; bad news, the rating donut shows up over the top border of the rating block, and not where I placed it. In fact, no matter where I place it, it always shows there.
    What am I doing wrong…?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor contactashish13

    (@rozroz)

    @bufus please share a screenshot of what the result is and a mockup of what exactly you want to achieve so that we can try to help you.

    Thread Starter bufus

    (@bufus)

    Sorry for the late reply, I’ve been messing with everything a bit more, and I seem to have made it worse :/
    Meanwhile I switched to the block editor (I was using classic), and now the shortcode doesn’t work at all, no rating donut anywhere.
    And the visitor rating on the comments look like this: https://imgur.com/3MVMxfd
    Is this a known bug, or have I broken something…?

    EDIT: on a post made with classic editor, the rating donut shows right before the comments -> https://imgur.com/TcnbN2E

    ANOTHER EDIT: Found it! On a post made with the block editor, but inserting the code on single.php, the donut shows right in the middle of the page: https://imgur.com/undefined

    I would like to be able to show a preview of the rating (just the donut) on another part of the post (below the title, alongside with some other elements I have there).

    • This reply was modified 6 years, 3 months ago by bufus.
    • This reply was modified 6 years, 3 months ago by bufus.
    • This reply was modified 6 years, 3 months ago by bufus.
    Plugin Contributor contactashish13

    (@rozroz)

    @bufus it might be best to state your problem statement again because this thread has become very confusing.

    Thread Starter bufus

    (@bufus)

    Thanks, @rozroz , I understand.
    I’ll open another one and try to be clearer about the issue.

    Plugin Contributor contactashish13

    (@rozroz)

    Thanks @bufus. I’m closing this thread till then.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Help implementing snippet’ is closed to new replies.