2

I am using an :after pseudo selector to place some text after an element on my page. I would like for this text to be content managed using Advanced Custom Fields, but I am not able to get it to work. Here is my code:

<style>
    .hc-copy:after {
        content:"<?php the_field('hero_paragraph'); ?>";
        display:block;
    }
</style>

When the PHP is parsed, the content property is just empty on the page. Is this possible?

2 Answers 2

1

To make sure your fields are populated use the following code to print all the values that are set:

<?php
var_dump( get_fields() );
?>

The 'hero_paragraph' key should be present somewhere in the printed values.

0

If that piece of css is in any php file then it should work as you expect. so double check your ACF Field and make sure the field name is correct and some value is set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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