Accessing global variable in “CSS” (style.php)

后端 未结 2 1061
遇见更好的自我
遇见更好的自我 2021-02-09 20:18

I\'m doing a style.php CSS file so I can use some dynamic variables in the CSS within a Wordpress installation:



        
2条回答
  •  野性不改
    2021-02-09 20:54

    To access the wordpress functions you need to include the following lines on top of your style.php file.

    define('WP_USE_THEMES', false);
    require('./wp-blog-header.php');
    

    The first line tells wordpress not to run theme related processes and the second line runs the wordpress engine. After this point you have access to the wordpress functions and the global variables.

提交回复
热议问题