Ok, seems that the problem is not related to the cache. But to the action execution order. If I update the value inside a page template (or inside a shortcode, that’s why I started my tests) the update fires after the render of the widget.
Solution: update the value inside an action. In this example you can use the 'wp' action:
function test() {
if ( is_page( 749 ) ) {
update_option( 'custom_check', 'a' );
} elseif ( is_page( 800 ) ) {
update_option( 'custom_check', 'b' );
}
}
add_action( 'wp', 'test' );
Related Posts:
- How to include checkbox in widget backend form?
- Limit the number of inactive widgets
- Nginx FastCGI_Cache Vs PHP Caching
- Create Image Uploader for Widget
- How to get the registered sidebar’s name by its id?
- Displaying a variable stored in functions.php inside widget
- Transform php code into a widget?
- How do I create a drop down menu in a widget?
- WordPress widget in custom theme
- How to allow PHP In WordPress text widget
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- Anything I can add to functions.php to make text widgets accept PHP?
- Show Specific Footer Widget for Specific Pages
- WordPress menu deletes when trying to add a hook
- How to clear WordPress Cache from Server/FTP/Remote location
- PHP contact form returns warning in text widget [closed]
- How can I add a specific, custom widget to my theme’s header.php?
- Get widget settings function?
- Widgets not showing in my custom theme
- Class ‘WP_Widget’ not found
- nowplaying.include.php Will Not Display Results
- PHP Code stuck in Cache [Memcached] [closed]
- How to group 2 radio buttons in a widget?
- I can’t get my custom widget area to show on my WordPress site
- How to run PHP code in Text Widget with no plugin in WP 4.4
- WordPress widget/sidebar dividers?
- custom widget on the footer
- Missing sidebar parameter “fix” – before_content
- Create onClick Event to Re-load a Widget
- How to put a variable in a instance in the widget
- How to output widget
- Extending the WP_Widget_Text class
- Dynamic Stylesheet loads but doesn’t finish
- How to combine wordpress_logged_in cookies in one cookie?
- WordPress Shortcodes.. printf is outputting a random number… Can’t figure out WHY?
- How to make my custom widget appear within WordPress widgets? Plugin development
- get widget number from array dynamically
- Passing UTM Parameters To Modify Page In WordPress
- Adding widgets to my plugin page instead of WordPress dashboard
- Hide subcategories (widget)
- Running code before object-cache.php runs
- Adding a widget function into the php theme file
- How to edit widget code to add unique class name to each div?
- If has $title in widgets
- Archives shortcode displaying above widget title
- Widgets in the loop if active
- Show latest posts in a plain HTML website custom widget [closed]
- Is it bad to add html to a widget by closing and reopening the php tags?
- Hook called before text widget save
- customize wordpress database error page
- Widgets not showing on custom theme
- WordPress transient not working with WP Engine
- My website is not showing Footer section
- WordPress widget and customize.php not working in Ubuntu16.04 VPS
- How can I display Custom Post type Custom Columns and its Content in a Dashboard Widget?
- How to use title attributes in sidebar widget?
- Show different website layout if no sidebar added
- display specific widget to a page
- Dynamically display font icons in widget
- Correct code to use php in text widget
- Stuck with sidebar registering
- Client cant see the Updated dynamic content
- How a HTML form can trigger a PHP function?
- Retrieve the whole widget sidebar and pass it inside an html
- Loading Widgets Via Child Theme
- How to stop hiding buttons forward / backward in pagination?
- How to create a widget with a populated dropdown?
- Language does not switch while cache is enabled
- Should I use wp_cache in my plugin to make it faster?
- Refresh page after login with litespeed cache
- Use WP Cron to Clear a Page Cache?
- I need to edit a widget, with no dashboard access
- is_user_logged_in() not working in homepage
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- (Who to follow) Twitter widget
- How save data on user’s client cache
- Widget Logic – display on page and all child
- Widget Update problems using a for loop
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- Beyond widget side menu editing, with the php page, custom template
- PHP: Why does my code work in index.php but not a widget?
- Non-static method error when trying to use class in widgets
- Widget edit and add in any page
- Slider from different widgets
- Even with PHP plugin get_posts not working in widget area
- how to run a php code in widget?
- WP_Widget dynamic field array with external AJAX
- List sibling pages widget, exclude current page
- Splash pages on a high traffic site
- Using existing widget code! [closed]
- Widget header unique classes
- Banner editable from backend
- Using a loop to build and update widgets
- Edit the Publish Widget Options
- how to check elementor is widget is active or loaded
- How to edit a widget code?
- How can I improve and optimise my wordpress web server for better performance in 2023
- WordPress PHP8.2 Critical Error in class-wp-widget.php
- Redirect to non-WordPress version of home page for search results via index.php customization overwritten
- Can’t programmatically log user in php