css - Possible to include ACF text field within inline style tag?

admin2025-06-03  8

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?

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?

Share Improve this question asked Feb 3, 2017 at 15:54 APAD1APAD1 4053 gold badges6 silver badges20 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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.

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748899866a314655.html

最新回复(0)