• I’m developing a block theme in a local environment. whenever i change custom properties in my theme.json file the changes are not taking effect.

    The changes IS reflected both when editing a page or navigation the new “Site editor”, but NOT when viewing a page.

    I can’t seem to find any documentation on my issue.

    • This topic was modified 3 years, 11 months ago by chrion.
    • This topic was modified 3 years, 11 months ago by Jan Dembowski.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Wish I could help but I’m pretty much in the same place you are.

    Thread Starter chrion

    (@chrion)

    The issue is due to the front-end reading the _transient_global_styles_theme_name from wp_options. This transient is not getting updated when i change my theme.json. I’m developing in a local VVV environment.

    Finally solved this! For performance purposes the WP team added caching to the global-styles output. You have to have WP_DEBUG = true in your wp-config.php to ensure caching is disabled during development. For more details see the issue in Github.

    Likewise, editing styles/theme.json files do not update on the front end. The only fix that works for me is to refresh the “Browse styles” page, and re-save.

    @onetrev thanks, works for me.
    define('WP_DEBUG', true);

    ezoulou

    (@ezoulou)

    Hi folks,

    Having the same kind of issue here : latest styles show ok in backoffice but not in frontend (which uses data from a very old theme.json version).

    I can fix this using either

    define( 'WP_DEBUG', true);

    or

    define( 'SCRIPT_DEBUG', true);

    Which is ok while developping.
    But I don’t want keep these when on production.

    Any tips on how to force clear theme.json cache?

    Cheers

    Thread Starter chrion

    (@chrion)

    @ezoulou i still use the solution i mentioned earlier in the post, where i have to dele the _transient_global_styles_theme_name row in the wp_options table

    ezoulou

    (@ezoulou)

    @chrion At first I didn’t quite understand your #post-15344825 proposal.
    But tryed it and it worked perfect!
    Thanks you very much. U saved my day! 🙂

    Still waiting for a fix for this. If I edit styles/new-style.json it does not reflect on the front end.

    Neither of these solve the issue for me:
    define( 'WP_DEBUG', true );
    wp transient delete --all

    Instead I have to go the wp-admin > Browse Styles. re-select the new-style and resave for the changes to take effect.

    Submitting a bug report here https://github.com/WordPress/gutenberg/issues/52041

    • This reply was modified 2 years, 7 months ago by Sunny.

    I believe that  define( 'WP_DEVELOPMENT_MODE', 'theme' ); which will be introduced in WordPress 6.3, fixes the issue.

    Had the same issue, tried clearing cache, set WP_DEBUG = true in the config file but that did not help.

    Only solution that worked was mentioned above by @frdmsun:

    I have to go the wp-admin > Browse Styles. re-select the new-style and resave for the changes to take effect.

    BigupJeff

    (@jeffersonreal)

    It seems theme.json and styles/[theme-name].json are cached differently. I’ve disabled webserver cache, browser cache and implemented the debug/dev constants mentioned:

    define( 'WP_DEBUG', true );
    define( 'SCRIPT_DEBUG', true );
    define( 'WP_DEVELOPMENT_MODE', 'all' );
    define( 'WP_ENVIRONMENT_TYPE', 'local' );

    My changes to theme.json now take instant effect after a page reload, but anything in a styles/[theme-name].json I have to follow the editor reset process described by @wpbred. Specifically:

    1. Navigate to editor > styles
    2. Hard reload Ctrl + F5
    3. Select and save another theme
    4. Re-select and save the theme with changes
    5. Reload front end to see changes
Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘theme.json is cached when viewing a page/post’ is closed to new replies.