Add text below WooCommerce short description if metabox value is true

Following the suggestion by @1inmillion, I put the second filter inside the first IF statement, which works nicely. This is the combined code: // 1. Add text below short description function bja_product_unavailable_text( $content ) { $content .= ‘<div class=”bja_product_unavailable”>This product is unavailable</div>’; return $content; } // 2. Remove add to cart button if product is … Read more

I want to allow certain file types on dokan upload files

You can try allowing mimes yourself, like this : add_filter(‘upload_mimes’, ‘custom_upload_mimes’); function custom_upload_mimes($existing_mimes) { $existing_mimes[‘rbxlx’] = ‘text/xml’; $existing_mimes[‘rbxlm’] = ‘text/xml’; $existing_mimes[‘rbxl’] = ‘text/xml’; return $existing_mimes; } If this doesn’t help, you need to look outside WP – it’s possible the server itself won’t allow those uploads. Can you access the .htaccess ? If so, you … Read more

WooCommerce, change “Add to Cart” to “Link to Product”, only for specific categories

You can just add another check within that filter – get the category of the product the filter is currently active on and compare it with the category you want to target. add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘replace_loop_add_to_cart_button’, 10, 2 ); function replace_loop_add_to_cart_button( $button, $product ) { if( $product->is_type( ‘variable’ ) ) return $button; // array of slugs … Read more

WPDB query suddenly not working

You should only interact with the DB via WP, not directly. It’s not a big deal in your case because you just want to see a value, but you’ll be more aligned with the best practices if you go in trying to solve a problem with $wpdb as a last resort. In your case, you … Read more

wp_script_add_data not working

the wp_script_add_data() method itself is not adding async attribute to the script tag. It just add a metadata to the script. As examples were already given earlier in few answers the following could work for you: wp_enqueue_script(‘pledge-js’, ‘https://www.pledge.to/assets/widget.js’, array( ‘jquery’ ), null, true); wp_script_add_data( ‘pledge-js’, ‘async’, true); add_filter(‘script_loader_tag’, ‘async_scripts’, 3, 10); function async_scripts($tag, $handle, $src) … Read more