Site logo

[Support request] Star_Bar implementation

Home Forums Support [Support request] Star_Bar implementation

Home Forums Support Star_Bar implementation

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2411134
    Denis

    Hello,
    I want to use revie stars. The following css I found in Davids gist:

    https://gist.github.com/diggeddy/ef3dc0315a73c0caad839c5348b89aa6

    I used simply css to write the css.

    In next step I use shortcode [star_bar] but nothing works, only text [star_bar] is shown.

    Can you help?

    Regards Denis

    #2411147
    David
    Staff
    Customer Support

    Hi there,

    did you try it with the required attributes?

    eg. [star_bar stars="2.6"]

    #2413234
    Denis

    Thanks for reply david.
    If I use required attributes, this have no effect.
    It still remain same. only text “[star_bar stars=”2.6″]” is shown.
    Do have another idea?

    #2413235
    Denis

    I used the following CSS:

    function make_star_bar( $atts ) {
    $value = shortcode_atts( array(
    ‘stars’ =>5,
    ‘color’ => ‘#f00’
    ),$atts);
    $percentage = 100 * $value[‘stars’] / 5;
    $html = ‘★★★★★

    .star-bar {
    background: linear-gradient(90deg, ‘. $value[‘color’] . ‘ ‘ . $percentage .’%, rgba(0,0,0,0) ‘. $percentage.’%);
    color: rgba(0,0,0,.2);
    background-clip: text;
    -webkit-background-clip: text;
    color: rgba(0,0,0,.2);
    }

    ‘;
    return $html;
    }

    add_shortcode(‘star_bar’, ‘make_star_bar’);

    #2413449
    David
    Staff
    Customer Support

    Aah the code is PHP.
    This doc explains where and how you should add it to your site:

    https://docs.generatepress.com/article/adding-php/

    TLDR:
    Are you using a Child Theme?
    If yes, then you can add the code to the Child Themes functions.php
    If No, then use the Code Snippets Plugin ( link in the above doc ) and add the code to a new snippet.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.