$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>css - Possible to include ACF text field within inline style tag?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin10PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far