Check when a setting has been changed

The update_option hook can use used to run an action when an option value has changed: function wpse_330204_option_updated( $option_name, $old_value, $new_value ) { if ( $option_name === ‘name_of_option_you_want_to_check’ ) { if ( $new_value !== $old_value ) { // Value has changed, run code here. } } } add_action( ‘update_option’, ‘wpse_330204_option_updated’, 10, 3 ); Just replace … Read more

Cookie cant be read even cookie is present

The $_COOKIE array contains only these cookies that came in the request from the browser. setcookie() adds an HTTP header asking the client to send the cookie during subsequent requests. So yeah – you can’t access $_COOKIE in the same request it is set.

wordpress hooks

I think I know what you are asking. The theme you are using is a fixed layout for each page and want to modify this layout for the home page. If this is true, most likely your theme is using templates and does not allow additional features, via plugins, to be used. Assuming the above, … Read more

Remove lines from RSS Feed

Turns out I don’t need to edit the RSS at all. The lines I’m looking to remove don’t originate in WP at all. They come from a Yoast SEO feature, and it can be turned off in the options: SEO -> Search Appearance -> RSS

add_image_size not working with after_switch_theme

The reason adding custom roles works on after_switch_theme is because roles are saved in the database. In fact, because it saves to the database, it should not run on after_setup_theme. add_image_size(), on the other hand, does not save anything to the database, so needs to run on every page load, and needs to be hooked … Read more

add_filter() inside another add_filter()

I would use do_action instead of add_filter. While similar, you are hooking into an action verse filtering a function. close, but different. function custom_get_availability( $availability, $_product ) { global $product, $bar, $progress; $stock = $product->get_total_stock(); $progress = 100-$stock; $bar = do_shortcode(‘[wp_progress_bar text=”Tickets Sold – ” pc=”.$progress.”]’); if ( $_product->is_in_stock() ) { $availability[‘availability’] = __($bar, ‘woocommerce’); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)