The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join

Functions

Get Featured Image URL with Fallback

Returns the featured image URL for a post and falls back to a default image when no featured image is available. Usage: $image = mytheme_get_featured_image_url( get_the_ID(), get_template_directory_uri() . ‘/assets/images/default.jpg’ );


Add custom classes to WordPress body

Add custom CSS classes to the WordPress <body> element using the body_class filter. This snippet demonstrates how to add classes based on the current page, post type, user state, or other WordPress conditions. It is useful for custom themes when you need to target specific pages or templates with CSS or JavaScript without modifying the […]



Automatically Resize Large Image Uploads

Automatically scales down oversized image uploads to a maximum width and height before WordPress finishes processing them. This helps prevent unnecessarily large files from being stored on the server, reducing disk usage and improving page load times, without requiring an image optimisation plugin.   1. Open your theme’s functions.php file. 2. Add the code above. […]


Prevent Footer JavaScript from Running in Elementor Editor

This snippet runs custom footer JavaScript on the frontend while preventing it from executing inside the Elementor Editor. It is useful for footer accordions, toggles, animations, and other jQuery-based scripts that manipulate the page DOM. By detecting the elementor-editor-active class, the script exits early when the Elementor Editor is active, helping prevent unnecessary JavaScript execution […]


ACF Image Field Fallback to Featured Image

This snippet displays an ACF image field when an image is available. If the ACF image field is empty, it automatically falls back to the post’s Featured Image. This is useful for WordPress listings, blog cards, custom post types, and archive templates where you want to give priority to a custom ACF image while keeping […]


Disable WooCommerce Product Image Zoom

WooCommerce adds a zoom effect to product images by default. If you prefer a simpler product gallery or your theme already provides its own image behavior, you can disable the built-in zoom feature. Steps Open your theme’s functions.php file. Add the code below. Save the file. Clear your website cache and refresh the product page. […]


Disable WooCommerce Cart Fragments

WooCommerce can use cart fragments to update the mini cart automatically. If your website doesn’t need this feature, disabling it can reduce unnecessary AJAX requests and improve page performance. Steps Open your theme’s functions.php file. Add the code below. Save the file. Clear your website cache and test the cart. Done — the WooCommerce cart […]


Remove the “Order Notes” Field from WooCommerce Checkout

If you don’t need customers to leave additional instructions during checkout, you can remove the Order Notes field to create a simpler and faster checkout experience. Steps Open your theme’s functions.php file. Add the code snippet below. Save the file. Refresh the checkout page. Done — the Order Notes field will be removed from the […]


Hide the WooCommerce Coupon Field on the Checkout Page

The coupon field on the WooCommerce checkout page isn’t always necessary. If your store doesn’t use coupons or you want a cleaner checkout experience, you can easily remove the coupon form using a simple code snippet. Steps Open your theme’s functions.php file. Add the code snippet below. Save the file. Refresh the checkout page. Done […]


Proudly supported by