• Resolved Mahmoud Hossam

    (@moodyhosam)


    Hello Sydney team,

    I hope you are having a good day. I was facing a caching problem related to the theme style sheets while using Sydney child theme. I found that the style sheets were always loaded with version "20230821" which prevented any changes in the child theme styles to be reflected unless the browser cache was cleared, even after changing the child theme’s version.

    I think the fix for this problem is to update line 310 in the Sydney parent theme’s functions.php
    from:
    wp_enqueue_style( 'sydney-style', get_stylesheet_uri(), '', '20230821' );
    to:
    wp_enqueue_style( 'sydney-style', get_stylesheet_uri(), '', wp_get_theme()->Version );

    This works for both parent and child theme.

    Regards,

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Actually, using a hard-coded version in the parent theme is intentional and the correct approach. By keeping a fixed version, the parent stylesheet isn’t reloaded unnecessarily every time the site loads, which improves caching and performance. The version only needs to change when the parent theme itself is updated, not every time a child theme changes its CSS.

    The child theme CSS always loads after the parent CSS, so it will override parent styles as long as the selectors are equal or more specific. If a child theme style seems not to apply, it’s usually due to selector specificity, not the hard-coded version. In that case, the child theme can simply increase selector specificity or use standard overriding methods to ensure its styles take precedence.

    In short, the hard-coded version is not a problem, it’s proper caching behavior, and the child theme works correctly on top of it.

    Thread Starter Mahmoud Hossam

    (@moodyhosam)

    Hello Masood,

    The correct approach is to enqueue styles with a constant version, not hard-coded.

    A hard-coded version results in the following at the front-end (using Sydney child theme):

    ...
    <link rel='stylesheet' id='parent-style-css' href='https://fayza.co.uk/wp-content/themes/sydney/style.css?ver=6.8.2' type='text/css' media='all' />
    <link rel='stylesheet' id='sydney-google-fonts-css' href='https://fayza.co.uk/wp-content/fonts/26e17d00d2b4a5b68937946aaa007f7e.css?ver=20250902' type='text/css' media='all' />
    <link rel='stylesheet' id='sydney-style-css' href='https://fayza.co.uk/wp-content/themes/mh-webdesign/style.css?ver=20230821' type='text/css' media='all' />
    ...
    • In the first line
      The parent styling is loaded through the child theme.
      The child theme doesn’t pass any version argument while enqueuing the styles, thus the current WordPress version is used
    • The second line
      A font styling is enqueued by the parent theme
      A hard-coded version "20250902" is passed, but it isn’t a problem here
    • The third line
      The child theme styling is loaded using the parent’s theme functions.php
      A hard-coded version "20230821" is passed while enqueuing, which creates the caching problem when I updated the child theme or change the style.css file.
      Wasn’t changed/updated since Sydney 2.26

    Using a hard-coded version defies the main reason we use child themes; to be able to customize the theme and style.css without being overridden by the parent theme or its updates.

    My solution suggests a constant version as a long as the currently active theme isn’t updated, either Sydney itself or the child theme.

    Regards,

    Hi Mahmoud Hossam,

    When Sydney releases a new version, they update both the CSS content and the version number in functions.php (if the CSS is updated), so the hard-coded version always reflects the actual file state, this method ensures proper caching and works well.

    Managing separate versions for each file can feel a bit tedious, but from a technical standpoint, it’s the right approach, stylesheets should only reload when they’ve actually been updated.

    Regards,
    Masood

    Hi @moodyhosam,

    Thank you for bringing this issue to our attention.

    We have discussed the issue internally and we agree with your suggestion of removing the hard coded value. We have noted this down internally and we’ll be addressing this in a future theme update.

    I hope this helps. Please let me know if you have other questions.

    Thank you!

    Thread Starter Mahmoud Hossam

    (@moodyhosam)

    This is good news, thank you @kmacharia & @masoodmohamed!

    I am going to mark it as resolved and I will be waiting for your next update.

    • This reply was modified 8 months, 2 weeks ago by Mahmoud Hossam. Reason: bad american accesnt 😜
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Theme Versioning & Caching’ is closed to new replies.