I want to get post thumbnail into kk Star Ratings. I use this code: <img src="<?php the_post_thumbnail_url(); ?>" />'; But it not working.

I inserted to index.php file, as:

<!-- kksr-stars -->
                <div class="kksr-legend">
                        <img src="<?php the_post_thumbnail_url(); ?>" />';

            $markup .= $this->ratings_as_legend($id);

            $markup .=
                <!-- kksr-legend -->
            <!-- kk-star-ratings -->

I dont know where you are using/inserting this code, but maybe you need the current post ID. Try using get_the_post_thumbnail_url( <post-ID> ,<thumbnail-size> );
To get the ID of the current post you can for example use $current_id = get_the_ID();. Than you can try $src = get_the_post_thumbnail_url( $current_id ,'post-thumbnail' ); to get the URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.