- This topic has 7 replies, 4 voices, and was last updated 3 years, 4 months ago by
David.
-
AuthorPosts
-
November 22, 2022 at 1:48 pm #2427951
Erika
Hi there,
I added some nice stars to a block and they are set to inline-width. In Backend they display properly, in Frontend under each other. Could you help me to fix this?
Thanks, Erika
November 22, 2022 at 4:56 pm #2428100Ying
StaffCustomer SupportHi Erika,
The GB style isn’t loading on your site.
Can you go to dashboard > GenerateBlocks > settings, and hit the
Regenerate CSSbutton?If it doesn’t work, can you switch it to
Inline CSS?Also, disabling the cache plugin might be worth a try.
Let me know if this works.November 23, 2022 at 1:04 am #2428488Erika
Hi Ying,
I did all 3 steps, no result 🙁
Inline CSS is set as well as in the customizer as in GB settings, Cache plugin deactivated.If I add icons to the site, they work. See the snowflakes above the block. In this case, the icons are part of the blog post content and are pulled in the query block with the “whole content” block of WP, because GB does not have that option 🙁 I guess that is the reason, but how do I get around this problem?
Another idea was to use GBs dynamic content and give out the excerp with 200 words (basically the whole blog post), however the stars are ignored completely in this case.
Any idea to solve this?
Or any other idea to think differently? I´d like to manually control how many stars a testimonial has without using another plugin and without pulling the testimonials from google. We´d rather add them as blog post and display in a query block.
Thanks, Erika
November 23, 2022 at 1:27 am #2428522Fernando Customer Support
Hi Erika,
Let’s check if a database-saving issue occurred. Can you try to recreate the stars from scratch?
Let us know how it goes.
November 23, 2022 at 1:35 am #2428539Erika
Hi Fernando,
nope. Even Worse :D, not it does not even take the size of icon.
What´s next? Could it be that the WP block deletes all styles and displays only text?
Erika
November 23, 2022 at 3:19 am #2428715David
StaffCustomer SupportHi there,
i would approach this differently:
1. Add a Custom Field to your Post with a name of
starsand give it your star valie.
This way we have the value saved in the Post Meta.2. Add this PHP Snippet to get the value and create our HTML and CSS for displaying the stars:
add_filter( 'render_block', function( $block_content, $block ) { $id = get_the_id(); $starValue = get_post_meta($id, 'stars', true); if ( $starValue && ! empty( $block['attrs']['className'] ) && 'star-rating' === $block['attrs']['className'] ) { $percentage = 100 * $starValue / 5; $color = '#ff0000'; $block_content = '<span class="star-bar-' . $id . '">★★★★★</span> <style> .star-bar-' . $id . ' { background: linear-gradient(90deg, '. $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); } </style>'; } return $block_content; }, 10, 2 );3. Now in your Query Loop or in your Single ( or where ever you want to display it ) add a GB Headline Block.
3.1 Just add some static text to the block eg.star rating
3.2 In Advanced > Additional CSS Class(es) add:star-ratingThe PHP snippet in #2 will replace the headline block with a Star bar.
November 23, 2022 at 7:14 am #2429068Erika
Hi David,
there´s always trust in you 🙂 Thank you for this solution. It´s beautiful.
Erika
November 24, 2022 at 2:01 am #2430569David
StaffCustomer SupportGlad to be of help 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.