This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Reply To: Dynamically Generate Static CSS with PHP

Jason Bobich


This is a very interesting concept.

Ok, so I think the problem is pretty simple, and is what you’re already eluding to. Basically you just need to manually pull the options from the database with default WordPress functions.

The reason is because you’re trying to call themeblvd_get_option literally at the point WordPress includes the Child theme’s files, which is before anything has actually been run yet or been setup. So, themeblvd_get_option will not do anything just yet, as there is no global array for that function to pull from just yet.

The framework saves all of your theme options into a single, standard WordPress option as one big multi-dimensional array. That means you can use WordPress’s get_option to retrieve it manually. The option ID used with WordPress is a filterable text string that, by default, is generated based on the name of your current theme. So, this will correspond to the name of your Child theme.

So, at the top of your dynamic CSS file, this is how you’d retrieve these options:

$option_name = themeblvd_get_option_name();
$options = get_option( $option_name );

Or more concisely:

$options = get_option( themeblvd_get_option_name() );

And now where ever you were trying to retrieve an option like this:

themeblvd_get_option( 'whatever' )

Instead, you’d just grab it from the array you pulled like this: