Add html + script with ACF field


I want to add an html code to an ACF field (what field?)
(example) <div id="arcomplete" data-cred="928.ODYxMTg0" data-product="75959"></div><script src=""></script>
which loads a .js cart to a page.

I’m not a developer like some of you so I wonder how to approach this? What element must I choose in Cwicly to dynamically load this?

Thanks in advanced

Just to clarify - is it that you want to load the html code into the page from an ACF field?

If you just want to put the above code into a page - you could do so via the Cwicly Code block.

Simply paste it into the PHP area of the code block (ensuring that you have first enabled PHP from the Role Editor Code block settings).

If you want to dynamically load that code from an ACF field that requires something more dynamic and depends where the ACF field is located (e.g. in a Post, Options page, etc).

Thanks. Yeah, I want to dynamically load the code from ACF.
Its an event-like Custom Post Type. Every post can have this field.

1 Like

Hi @webmaat, The answers are here in the ACF docs:

You can either use the php code directly within a code block, or load the shortcode dynamically.

1 Like

Thanks, but I still don’t know how to add this code. Like I said, I’m not a developer

No problem, everything is easy once you learn how.

You can display any field using:

<?php the_field('your_field_name'); ?>

This is assuming your code block is within the scope of a post (for example) that has a custom field called “your_field_name”.

Hopefully the naming is unambiguous enough to indicate that you should replace the name your_field_name with the actual name of the field as you have created it in ACF.

ok, thanks! And this script that is in a ACF text field will run this way?

That outputs whatever is contained in the field.

Depending on how you are storing it and how you populate the data into the field in the first place, you may need to do some additional formatting, but the original html you posted seems straightforward enough, so it will probably output normally.

1 Like

Thanks for your effort in helping me!

1 Like