Adding ACF array to X shortcode

I am trying to get a value from an ACF field into a Skill bar shortcode.
But I am not very good at PHP, can you please help me?
The field type is number. I also tried get_field but it didnt work.

			  <?php echo do_shortcode("[x_skill_bar heading="SVÅRIGHETSGRAD" percent=\"$grad\"]");
				{
				$grad = get_field_object('svarighetsgrad', [$load_value]);
				}

?>

Try.

<?php echo do_shortcode('[x_skill_bar heading="SVÅRIGHETSGRAD" percent="'.get_field_object('svarighetsgrad', [$load_value]).'"]'); ?>

Thanks, I tried but it doesnt seem to work. The output code looks like this:

<div  class="x-skill-bar" data-x-element="skill_bar" data-x-params="{&quot;percent&quot;:&quot;&quot;}">

Ifound a solution that solved that problem but I faced another problem.
Here’s the solution:

 <?php echo do_shortcode('[x_skill_bar style="background-color: #222" heading="SVÅRIGHETSGRAD" percent="'.get_field('svarighetsgrad').'"]'); ?>

Here’s my other problem, when the bar is 100% it’s only half filled.
See images…

Solved it! I needed to add “%” to the value:

<?php echo do_shortcode('[x_skill_bar style="background-color: #222" heading="SVÅRIGHETSGRAD" percent='.get_field('svarighetsgrad')."%".']'); 
		  ?>

Glad that did the trick.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.