WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Versioning TwentyTwelve's CSS (4 posts)

  1. coopersita
    Member
    Posted 1 year ago #

    Hi,

    I'm making a child theme for TwentyTwelve, but my host is caching my files, so I'm not seeing the changes I do to my style.css file.

    Is there a way to version the stylesheet for my child theme?

    Thanks

  2. coopersita
    Member
    Posted 1 year ago #

    Ok, so what I did to fix it, is add a functions.php to my child-theme, and added the following:

    <?php
    function my_theme_styles() {
        wp_enqueue_style('my-theme-style', get_bloginfo('template_directory') . '/style.css', false, date('h:i:s'));
    }
    add_action('wp_head', 'my_theme_styles');

    So it loads the stylesheet twice, which is not ideal, but while the site is being developed, it helps keep the stylesheet fresh.

  3. coopersita
    Member
    Posted 1 year ago #

    Actually, this code will work. I had the wrong path to the theme's folder:

    <?php
    function my_theme_styles() {
        wp_enqueue_style('my-theme-style', get_stylesheet_directory_uri(). '/style.css', false, date('h:i:s'));
    }
    add_action('wp_print_styles', 'my_theme_styles');
  4. Andrew
    Forum Moderator
    Posted 1 year ago #

    Thanks for sharing :)

Topic Closed

This topic has been closed to new replies.

About this Topic