Add an Automatic ‘Featured Image’ to Blog Posts Based on Category
Using featured images in post archives is a common feature of themes, but sometimes you might want to use featured images a bit differently. Occasionally I’ve worked on sites where the images to be displayed relate to the category a post is in and not to the post itself. Instead of adding the same featured […]
How to define a default post thumbnail (2 methods)
Two simple ways to correctly define a default post thumbnail (i.e., featured image) in WordPress. I’ve seen a few tutorials floating around the WordPress-o-Sphere about setting a default post thumbnail for WordPress’ featured image functionality. Some involve tactics like saving a permanent default image (theme authors, please don’t do that). A default thumbnail is generally […]
Add Fallback Image as Post Thumbnail Manually
First, you need to create an image that you want to use as the default image. Next, you need to upload it to your theme’s images folder using a FTP client. Your theme’s images folder is located inside /wp-content/themes/yur-theme/ folder. If it doesn’t have the images folder, then you need to create it. After you have uploaded the […]
Reduce Image Bloat in WordPress And Get Rid Of Unused File
If you use a lot of photos and graphics on your WordPress site, you’ve probably accumulated a tonne of image files on your server that you have no use for. This is a quick and effective strategy for cutting down on excess image files and only keeping what you actually need. The image bloat problem When you […]
Image sizes in WordPress
A user asked me a few days ago how to get the image width and height of a custom-defined image size in WordPress. After searching through the WordPress source code, I couldn’t find a function that handled this. I suppose there really aren’t too many uses for it, but this user needed these values for […]
Setting a Fallback for Post Thumbnails in WordPress
One of the countless things that I love about WordPress is how easy and efficient the process of adding new content is. All you have to do is provide the art and copy and your theme will take care of the rest. While this workflow is usually smooth, there are times the end user can […]
How To Require a Featured Image Before You Can Publish a Post
Are you looking for a way to require a featured image before you can publish a post? This snippet will require that you have added a featured image before your post can be published. If you try to publish a post without a featured image after adding this snippet, you will receive this message: “You […]
Slick Slider WordPress Without Plugin | Slick Carousel
In this blog we will learn how to add a slick carousel in a WordPress Theme without using any plugins. There are couple of ways you can add a slick carousel in WordPress: Using slick-carousel npm package, or, Download required slick files. In this blog we will learn the second way, by downloading the slick files. […]
How to Add Images to Media Library after Uploading them in PHP Programmatically
When you upload files from WordPress admin area, they will automatically appear in Media > Library. But what if you want to create a custom file uploader specially for your website visitors? Step 1. As usual, we Begin with HTML Form What is important to remember here? I placed the PHP file process_upload.php into the theme directory, if you […]