WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created an options page for my theme, where I can manually edit the CSS.
Lets say I change the CSS in the options page for the <H1> tag, so it will now change it on the front-end.
What I want to also do is have it change in the visual editor.

I have added the function


and in the style.php I have it saying in the top

header('Content-type: text/css');

so it recognizes the file. But now I can't get the options dynamically...

How should I achieve this?


this is in the functions.

add_filter( 'mce_css', 'cnote_visual_css' );
function cnote_visual_css() {
    return get_bloginfo('template_directory') . '/cnotethegr8/global-style.php';

this is the global stylesheet

header('Content-type: text/css');
global $shortname;

h1 { <?php echo(get_option($shortname.'_style_h1')); ?> }

when i echo $shortname nothing shows...

share|improve this question
Do you have a problem loading that style.css file in the editor, or do you have a problem reading your plugin settings in that file? Can you edit your question to make this clear? – Jan Fabry May 27 '11 at 11:55
Could this be due to tiny mce and your browser caching the old stylesheet? Maybe try adding a random generated number to add_editor_style("style.php?v=".rand()); – Brady May 27 '11 at 13:27
@Brady: So i thought it was to the version generator, but i fixed that problem. Basically the php options arent being recognized. For instance if i echo get_bloginfo('name') nothing is printed. but the php itself does work with a test of $this = 'hello'; echo $this; – cnotethegr8 May 27 '11 at 13:50
Ok I think I might know your answer but need to see your code to say for certain. Please post your dynamic stylesheet code as the way you think it should be. – Brady May 27 '11 at 13:56
up vote 1 down vote accepted

The reason why this isn't working is because the WordPress core isn't loaded when this dynamic style sheet is loaded. get_option() hasn't been defined yet.

What you need to do is load WordPress at the top of your dynamic stylesheet:

share|improve this answer
great!!! thanks a lot! – cnotethegr8 May 27 '11 at 15:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.