- Using Heading Block
- Buttons
- Post Grid
- Content Timeline
- Social Share
- Google Map
- Add Testimonials
- Info Box
- Section
- Team
- Icon List
- Price List
- Post Masonry
- Post Carousel
- Importing Starter Templates With Spectra
- Post Timeline
- Call To Action
- Advanced Columns
- Troubleshooting: Missing Icons
- Filters/Actions For Post
- Blockquote
- Spectra Patterns
- Contact Form 7: Multiple Column Fields
- Contact Form 7: Checkbox / Radio / Acceptance Control
- Unable To Style Contact Form 7
- Marketing Button
- Tab Index For Multiple Gravity Forms
- Getting Started With Spectra
- Manually Install Spectra Via FTP
- Table Of Contents
- How-to Schema
- FAQ’s: Schema/Accordion
- Inline Notice
- WP – Search
- Exclude Heading From TOC
- Review Schema
- Lottie
- Taxonomy List
- Tabs Block
- Block Display Conditions
- Create Contact Forms
- Import Single Pages, Templates, & Block Patterns
- Enable/Disable Design Library Button
- Update Folder File Permissions
- Assets API For Third-Party Plugins
- Star Rating
- Masonry Image Gallery
- Wireframe Blocks
- Copy & Paste Style
- Coming Soon Mode
- Load Google Fonts Locally
- Container Flex Property
- Default Content Width
- Blocks Editor Spacing
- Heading Block
- Image Block
- Buttons Block
- Translate Everything WPML
- Container Block
- Collapse Panels
- Responsive Conditions
- Taxonomy Styling Options
- Block Presets
- Image Gallery
- Counter Block
- Modal Block
- Registration Form Block
- Dynamic Content Extension
- Slider Block
- Pagel Level Custom CSS
- Countdown Pro
- Slider Custom Navigation
- Instagram Feed
- Loop Builder
- Animations
- Login Form Block
- Site Visibility
- Global Block Style Extension
- Spectra Actions: Clear Cache
- Create Popups
- Quick Action Bar
- Custom Blocks
- Move Block Patterns
- Grid Builder
- Move Title Bar To Top
- Resolving Container Layout Conflicts
- Newsletter Forms
- Register High-Privileged Users
- User Roles Access To AI
- Database Update Instructions (Below 2.0.0)
- FAQ's: VIP Priority Support
- Whitelist Email Address
- Hide Core Blocks
- Regenerate Assets With Code
- Using ACF Repeater Field in Spectra
- Pixabay Image Search Feature
- Getting Started with Instagram
- How to Fix Stretched Spectra Images in WordPress 6.7
- How to Change Breakpoints in Spectra?
- Controlling Access to the Spectra Design Library Based on User Roles
- Advanced Loop Builder
- Multi-Column Form Block Using Utility Classes
- Why Am I Seeing Mixed Content or Non-HTTPS Errors?
- Preview Options (Desktop, Tablet & Mobile)
- Transparent / Sticky Header
- Change Site Logo
- Change Global Styles
- Disable Title on Posts & Pages
- Transparent / Sticky Header For Single Page / Post
- Change Header & Footer Patterns
- Custom / Google Fonts
- Reset Global Default Styling
- Manually Install Spectra One Via FTP
- Enable / Disable Header & Footer On Specific Pages / Posts
How to Regenerate Spectra Assets Using Custom Code
The ‘Regenerate Assets’ button under Spectra > Settings > Asset Generation allows users to regenerate CSS and JS assets:
For example, if you update your site and visitors still see old styles, regenerating assets fixes this.
By doing it programmatically, you can trigger the refresh through your plugin or backend, saving time with every website update.
Regenerating Spectra Assets Automatically
Spectra regenerates its CSS and JS files by updating something called the asset version (__uagb_asset_version).
To trigger this, we can update that version number using a custom function in your functions.php file. This is how you can automate it:
Step 1: Update The Asset Version
You can update the asset version using the update_option() function in WordPress, like this:
update_option( '__uagb_asset_version', time() );
Note: The time() function ensures a unique timestamp is used, forcing Spectra to regenerate the assets.
Step 2: Hooking The Version Into Actions
You can set this process to run automatically when certain actions happen on your site, like saving a post.
To do that, you add this code to your functions.php file:
add_action( 'save_post', 'regenerate_page_assets', 10 );
function regenerate_page_assets() {
// Update the asset version to trigger regeneration
update_option( '__uagb_asset_version', time() );
}
This code hooks into the save_post action and tells WordPress to regenerate Spectra’s assets whenever a post or page is saved. That way, your site’s CSS and JS files stay updated automatically.
You can hook this into various WordPress actions (such as save_post and more).
That’s all! If you have any questions, feel free to contact our support team.
We don't respond to the article feedback, we use it to improve our support content.