Tagged: 

Viewing 3 reply threads
  • Author
    Posts
    • #3617
      Gregg
      Member

      Hi Steve

      This might be more of a WordPress question rather than Piklist itself, but I could be wrong. I’ve setup my settings page where the user can define a color set for the site as you can see in the attached.

      Everything is working well, but I’m stumped as to how I generate the dynamic CSS from these settings that would override the theme’s CSS.

      Or put another way, I know what CSS code should be generated, but how and where this gets injected into the header is puzzling to me.

      Any thoughts?

      Attachments:
      You must be logged in to view attached files.
    • #3626
      Steve
      Keymaster

      @Gregg– You can use inline CSS in your theme’s . Try something like this in your theme’s functions.php file:

      add_action('wp_head', 'my_custom_css');
      function my_custom_css()
      {
        $options = get_option('YOUR-OPTION-NAME');
      ?>
      
       <style type="text/css">
          html {
            background-color: <?php echo $options['background-color']; ?>;
          }
        </style>
      <?php
      }

    • #3629
      Gregg
      Member

      You rock Steve! I was struggling and had no luck with wp_add_inline_style and of_get_option, but your solution is working very well indeed. Thanks so much.

    • #3630
      Steve
      Keymaster

      @Gregg– Glad it works for you. Closing ticket.

Viewing 3 reply threads
  • The topic ‘Settings – How to Generate Dynamic CSS’ is closed to new replies.