Support » Fixing WordPress » Using theme options to modify CSS

  • Hi.

    I had a look around and I couldn’t find an exact answer to this question…

    I’m making a theme at the moment, and I’m including some theme options. I have the basics working, but I need to know the ‘best practice’ ways of doing a couple of things.

    Specifically, I want users of my theme to be able to set their own link colour. To do this, I need to re-write the default link colour in my CSS file with whatever they want. As far as I am aware, you can’t directly use PHP in a CSS file (not without renaming it to something like styles.css.php, which I don’t want to do).

    A lot of themes allow this ability to set link colours — is there a standard or accepted way that they do this? How do they do it without using PHP in their CSS?


Viewing 2 replies - 1 through 2 (of 2 total)
  • They use css in their php! It can be printed as inline css using wp_head, which allows it to be output in the <head> section of the site

    add_action( 'wp_head', 'voodoo_inline_css', 100000 );
    if( get_theme_option( 'custom_css' ) )
    		theme_option( 'custom_css' ); 
    	do_action( 'voodoo_inline_css' );

    I have a custom_css option where users can input the css, then it gets added in

    Thanks for the info.

    I’m not sure I really understand you, though. The code you posted — where does that go? Into functions.php or somewhere like that?

    How would I add several CSS options for a user to mess with in the theme?


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using theme options to modify CSS’ is closed to new replies.