How to enable WordPress debug mode and log errors
To enable error logging, create an empty file named “php-errors.log”. Place it in a directory that is not publicly accessible (preferably outside your web root) and ensure it is writable by the web server. Then add the following code to wp-config.php:…
Remove query strings from static resources in WordPress
Use this to remove query strings from static resources in WordPress // Remove query strings from static resources function _remove_script_version( $src ){ $parts = explode( ‘?ver’, $src ); return $parts[0]; } add_filter( ‘script_loader_src’,…
Leverage Browser Caching in WordPress via .htaccess
Add this to your .htacess to Leverage Browser Caching ## https://crunchify.com/how-to-speed-up-wordpress-leveraging-browser-caching-via-htaccess/ ## EXPIRES CACHING ## <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access 1 year"…
How to delete all images from your WordPress site
Use this SQL to remove all images/documents/etc from your media library 1 – Run these in phpmyadmin DELETE FROM wp_postmeta WHERE post_id IN ( SELECT id FROM wp_posts WHERE post_type = ‘attachment’ ) ; DELETE FROM wp_posts WHERE post_type = ‘attachment’ 2…
Hide premium WordPress theme notifications
Most premium themes ask you to install additional plugins however if you dont install all of the plugins it recommends and keep them activated you will see a warning at the top of the admin area which comes back even if you close it. If you add this code to your…
Hide menu items in the WordPress Admin Area
Use this to hide menu items in the WordPress admin area that you do not use. <?php function remove_menus_links(){ remove_menu_page( ‘edit.php?post_type=portfolio’ ); remove_menu_page( ‘edit.php?post_type=team’ ); remove_menu_page( ‘edit.php?post_type=clients’ );…
Set a maximum image upload size in WordPress
This can be used to set a maximum image upload size in WordPress, this helps to stop clients uploading large image files. This example is 1.5mb <?php //limit image file size to 1.5mb function whero_limit_image_size($file) { // Calculate the image size in KB…
Move WooCommerce category description up to be full width
This will move the WooCommerce category description up to be full width instead of in the right hand column. <?php //move cat description up the page remove_action( ‘woocommerce_archive_description’, ‘woocommerce_taxonomy_archive_description’, 10 ); add_action(…
Remove WooCommerce long description title ‘Product description’
Use this to remove the hardcoded WooCommerce long description title ‘Product description’ <?php //remove long desc title add_filter( ‘woocommerce_product_description_heading’, ‘remove_product_description_heading’ ); function…
Add from before variable prices on WooCommerce
Use this in your functions file to add from before variable prices on WooCommerce <?php //add from before price function wc_wc20_variation_price_format( $price, $product ) { // Main Price $prices = array( $product->get_variation_price( ‘min’, true ),…
Recent Comments