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
- How display widget by id
- 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
- Check if widget has content
- 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
- display most popular tags in two columns
- List authors with posts in a category
- How to add Shortcode (font awesome) in widget title?
- 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
- dynamic sidebar not showing anything
- 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
- javaScript in section of WP API
- Style every second widget?
- PHP Code stuck in Cache [Memcached] [closed]
- How to group 2 radio buttons in a widget?
- Add before_content and after_content to register_sidebar
- PHP Deprecated: WP_RSSjb has a deprecated constructor
- 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
- WordPress with php 5.5 and zend opcache
- Missing sidebar parameter “fix” – before_content
- How to add just one specific page to widget without plugin?
- 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
- How to enable Zend Optimiser+ with Batcache
- Dynamic Stylesheet loads but doesn’t finish
- Dynamic Sidebars & Echo
- 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
- WordPress & Fastcgi proper setup?
- Dynamic content in template
- My own theme’s custom widget areas are not working
- Force ‘permanent’ post cache of shortcode results
- Widget Logic – display on page and all child
- Add disclaimer before certain posts and pages
- 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’?
- Fatal Error cannot log into wordpress and website disappeared
- Beyond widget side menu editing, with the php page, custom template
- How to list categories by page id in wordpress
- 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
- widget: input the px value from user and use it as inline style in widget function
- RegExp to EXCLUDE strip HTML (FOR SOMME) comments
- Slider from different widgets
- Even with PHP plugin get_posts not working in widget area
- Update title of every instance of widget using text field
- how to run a php code in widget?
- Are widget arguments always set inside My_Widget::widget()?
- WP_Widget dynamic field array with external AJAX
- WordPress – registering sidebar and adding a button directly after .textwidget
- List sibling pages widget, exclude current page
- Splash pages on a high traffic site
- Name Input from widget displays Sidebar name instead of saved data
- WordPress – show number of comments for each post in widget
- Using existing widget code! [closed]
- Widget header unique classes
- Banner editable from backend
- My custom widget won’t stay in the widget area after I refresh the widget page
- key( $GLOBALS[‘wp_registered_sidebars’] ) is always showing the same value
- How to change links in the 3 main categories, on widget category, to a javascript function call
- Using a loop to build and update widgets
- PHP Widget and do_shortcode
- Edit the Publish Widget Options
- How to define template directory in this widget code
- WP Debug enabled Undefined index error in a widget
- 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
- wordpress-plugin (widget) that performs a Neaby-search on the openstreetmap-endpoint: around x find y
- Can’t programmatically log user in php
- Trying to insert widget code into theme function
- “Object-cache.php” disables wp_cron and even disables my entire site, and keeps reappearing by itself again after I delete it