I’m not sure what other details I can go into.
To get the dynamic style sheet you are actually calling on WP’s AJAX request script https://codex.wordpress.org/AJAX_in_Plugins, this is what you are enqueuing. The
action=some_action part of the URL tells WP what hook to run.
You create an action filter and this action filter outputs the CSS, this can be done by either outputting it directly in the function or by including a separate PHP file that does the CSS. This would all look like a CSS file except for the dynamic parts that would be PHP.
The only thing that’s not included in the link I provided or in the documentation is that before you start outputting the CSS that you need to indicate that what is returned is in fact CSS. To do this, before outputting CSS you do
<?php header("Content-type: text/css"); ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.