Actually I’m making a generic personnal template with customization from the backend; something like in the premium themes.

So I made a “theme apearance options page” with ACF. I added fields like “h1 title” as repeater and “colors, fonts…” as subfields.

I made a specific css for my “customization theme” but to display the ACF fields I’m using a php file enqueued as stylesheet. When I’m enter the value like “$color =’#fff'” and echo it on the css tag it’s working.

My CSS.php:

if( have_rows('repeater', 'option') ):                  
    while( have_rows('repeater', 'option')): the_row(); 
        $FieldColor = the_sub_field('color');           

 <!-- Begin CSS -->
h1 {color: <?php echo $FieldColor; ?>;}

From the ACF support,my problem seems to be we can't enqueue a php as stylesheet like this

add_action( 'wp_enqueue_scripts', 'wpchild_enqueue_styles' );

function wpchild_enqueue_styles(){
        wp_enqueue_style( 'inu-media-style',get_stylesheet_directory_uri().'/inc/template/css-template/styles-css.php' );   

and make the functions, plugins values working. Do to that we have to enqueue the style script using admin-ajax.php .

Does anyone knows how enqueue my file.php as CSS with admin-ajax ?

  • Does this need to be in a file? Can't you just output the styles in a <style> tag? – Jacob Peattie Sep 6 '18 at 11:11
  • thanks for your answer, I prefere not there is a lot of fields – Lust Sep 7 '18 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.