How to Update post_modified of all wordpress post

You can use a generalized update query. As always, when dealing with databases take a backup first. With that out of the way, your query should look something like: BEGIN; — Start a transaction UPDATE wp_posts SET post_modified = <Your new date> AND post_modified_gmt = <Your new date in GMT>; SELECT * FROM wp_posts LIMIT … Read more

Remove item in Checkout

that function is deprecated, use wc_get_cart_remove_url( $cart_item_key ) instead if (is_checkout()) { $product_name .= apply_filters(‘woocommerce_cart_item_remove_link’, sprintf( ‘<a href=”%s” rel=”nofollow” class=”remove” style=”float:left;”>&times;</a>’, esc_url(wc_get_cart_remove_url($cart_item_key)), __(‘Remove this item’, ‘woocommerce’), esc_attr($cart_item[‘product_id’]), esc_attr($cart_item[‘data’]->get_sku()) ), $cart_item_key); return $product_name; }

Compare $_POST returned values with term array

Just check if $_POST contains key with id of correstponding term. if (isset($_POST[‘recvid’][$term->term_id])) { However, I would not loop through all the terms. get_terms function has corresponding option. So, to receive all posted ids, you would do this (also note, that first parameter may be a string, no need for an array): $brands = get_terms(‘recipebrands’, … Read more

preg_replace regex problem

I finally got it figured out. In order to see the content that I was trying to edit, I turned on debugging in wp-config.php: define(‘WP_DEBUG’, true); // set true if ( WP_DEBUG ) { define(‘WP_DEBUG_LOG’, ‘../logs/debug.log’ ); define(‘WP_DEBUG_DISPLAY’, false); // don’t display errors on pages @ini_set( ‘display_errors’, 0 ); } Then, in the function that … Read more

What is the alternative code to if (isset ($_POST) && !empty ($_POST) to avoid warnings?

filter_input is the proper way to go. If it doesn’t return anything valid, it will return null: $myvar = filter_input( INPUT_POST, ‘something’, FILTER_SANITIZE_STRING ); if ( empty( $myvar ) ) { // Do whatever you would have done for ! isset( $_POST[‘something’] ) } // Use $myvar filter_input won’t throw any notices if the requested … Read more

Using Argument from Function to Re-Direct Visitor (WordPress)

The problem is the variable $sountry – and this is because of something called variable scope – https://www.php.net/manual/en/language.variables.scope.php – the variable is only available within the function, as you do not “export” it or make it globally available – here is an update to your functions to show how this might work: function visitor_ip_and_country() { … Read more

Can I make get_users() query global?

You can use the WordPress functions apply_filters and add_filters to store and retrieve data, like so: // The filter callback function. function so_wp_380975_get_user_args( $array ) { // (maybe) modify $array. // for now, we just return the array return [ ‘meta_key’ => ‘mycred_default’, ‘orderby’ => [ ‘meta_value_num’ => ‘DESC’ ], ‘order’ => ‘desc’, ‘number’ => … Read more