If you are changing your theme, you likely should generate images in the sizes your theme uses. Three common sizes would be the largest an image is displayed on desktop, tablet, and mobile. There is also going to be the size of image thumbnails.
If you are using a CDN such as Cloudflare, the CDN will take care of this for you. I definitely recommend using a CDN for page caching, and image optimization, and delivering your site as fast as possible.
If you don’t use a CDN, you can make images the sizes your theme uses, easily
WP-CLI
If you have SSH access, use WP-CLI:
wp media regenerate
for the options see:
wp help media regenerate
With a Plugin
https://wordpress.org/plugins/force-regenerate-thumbnails/ is maintained, currently says works with WP 6.7.2
The solution is simple: have your wp-config.php define $SERVER[“HTTP_HOST”] if it is not set.
Many hosts don’t define this, as it isn’t needed for normal traffic. But bots, or people for some weird reason accessing your site by IP address or with a very old browser, will generate errors that clutter up your site error log.
Also, you using SSH to maintain your site in wp-cli, will often not have this set.
How to Fix It
You might be able to modify your wp-config.php file directly. Or your hosting company (especially WordPress managed hosting accounts) will require you to modify it via their user dashboard. For example, in Sites, Settings, Wp-config, “Additional wp-config.php content”.
A good place to add the code would be before this:
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
Or right before the common (but not always there) line with /* That's all, stop editing! Happy publishing. */
Warning: if you are not comfortable editing your wp-config.php file, or don’t know the basics of PHP code, then have your “computer friend” do this for you. Or have your hosting company do this for you.
Note: many sites online suggest $_SERVER['HTTP_HOST'] = 'example.com'; or some other “dummy URL”, but that won’t work in wp-cli on a WordPress Multi-Site where define('DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST'] ); tells WordPress what site to use.
Is your wp-cli using an old version of PHP, older than WordPress runs in? If you get errors in wp-cli, for example with wp plugin list, about a plugin needing a newer version of PHP, this is how to fix it (temporarily).
Sometimes website hosting companies upgrade your WordPress PHP version, but fall behind updating the PHP version for your SSH terminal connection to the site.
The long-term solution is get your hosting company to update the ssh version of PHP.
Boo, hiss to those negligent website hosting companies. They should always keep PHP versions updated, at least above the minimum recommended version for WordPress. In June 2023, that minimum is PHP 7.4. It is currently very common now for sites to be running on PHP 8.1 or newer. Even though the recommended minimum version of PHP for WordPress is PHP 7.4, I suggest don’t run WordPress anymore on PHP older than PHP 8.1, and it’s better to be using PHP 8.2 or newer.
Plugin authors are starting to use the good enhancements in newer versions of PHP, setting their minimum PHP version to 7.4. Good for them!
This error is not the plugin author’s fault. It is the hosting company’s fault, for still having an old version of PHP in use.
Here is the full error message for one plugin, but understand that each plugin will have a different message. The important part is this: dependencies require a PHP version ">= 7____" whatever the version number is.
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7.3.33-1+0~20211119.91+debian9~1.gbp618351. in /_____/wp-content/plugins/woo-store-vacation/vendor/composer/platform_check.php on line 24
That site’s SSH terminal is running PHP 7.3.__ (even though WordPress on that site is using PHP 8.1), while the plugin requires at least PHP 7.4.
Solution (the hard way):
Change the wp-cli command to tell it to skip running the plugins that require a newer PHP. This is harder because you have to type so many characters for so many commands.
For example, change wp plugin status to
wp plugin status --skip-plugins=ti-woocommerce-wishlist,woo-store-vacation
That “skip plugins” is a comma-separated list of the folder names of the plugins that require a newer version of PHP than your hosting company provides for your SSH terminal.
Remember, if WordPress itself is being run in too old a PHP version, this won’t fix it. Have your hosting company run WordPress in a newer version of PHP, minimum version 8.1. If they can’t do that, eww, move to a better hosting company!
How do you get a list of the plugins that need to be excluded? It’s right there in that error message. See “wp-content/plugins/woo-store-vacation/” in the error?
So in this case, –skip-plugins=woo-store-vacation
If you run wp plugin status again, you may see another plugin that has the same issue. Next time I ran that command, I saw “wp-content/plugins/ti-woocommerce-wishlist/” so, the new command includes --skip-plugins=ti-woocommerce-wishlist,woo-store-vacation .
Everything from “/plugins/” to the next “/”, and separate each of them with a comma and no spaces. The order of the plugins doesn’t matter.
Which wp-cli commands need this?
Many of them. Most of the commands that I use every time I am updating plugins and checking every plugin is okay and every administrative user is okay.
What is the Easy Way?
Instead of modifying each wp-cli command, tell wp-cli to always use the settings you need.
You can set global settings for wp-cli in a wp-cli.yml file in the WordPress root folder.
The hosts I use happen to all have nano as the text editor. Ask your hosting company what text editor to use.
Navigate to your WordPress root folder (the folder with wp-admin/ and wp-content/ ). Edit wp-cli.yml (you are likely making a new file, so it is empty, unless you created one before).
nano wp-cli.yml
Add a line like this, adjusting it to exclude your set of plugins:
Most people do plugin, theme and WordPress core updates via the WordPress Update page.
But if you are managing multiple sites, you might find it’s easier for you if you use the command line.
Once you are logged into the site via SSH (a secure encrypted text-based terminal for accessing your web hosting account’s files and many Linux commands), then many WordPress command line functions are available to you.
One requirement: you have to be using a website hosting company that gives you access to the command line, via SSH. I recommend SiteGround for hosting almost all sites.
WP-CLI works in your WordPress folder (for most people, that’s the public_html folder, aka the www folder). It also works in WordPress sub-folders, e.g. ~/www/wp-content/
cd ~/www
Plugin and Themes Updates
Get a list of plugins your site uses:
wp plugin list
Plugins that need updates:
wp plugin list --update=available
Update all plugins:
wp plugin update --all
Update all plugins excluding WooCommerce (or any other plugin that itself has plugins, and therefore you should update all the plugins-plugins first and then update the main plugin). Substitute the name of the plugin, from the “wp plugin list” command:
wp plugin update --all --exclude=woocommerce
Updating Your Themes
wp theme list
wp theme update --all
Updating WordPress Core from SSH
wp core update
What Other WP-CLI Commands Are Available?
wp help
That shows you a list of commands, and a brief description. You can then get help on any of those commands
wp help core
Many of the WP-CLI commands have several levels, and several parameters. For example:
wp user create bob bob@example.com --role=author
So use “wp help user create” to see what the available parameters and options are for the “wp user create” command.
If you simply type the command without the required parameters, you will get a brief usage prompt.
wp user create
usage: wp user create [--role=] [--user_pass=] [--user_registered=] [--display_name=] [--user_nicename=] [--user_url=] [--nickname=] [--first_name=] [--last_name=] [--description=] [--rich_editing=] [--send-email] [--porcelain]
Some plugins have their own WP-CLI access, check the plugin’s documentation or the “wp help” list.
The help documents are displayed using “less” (the Linux command for paging through a text document, at least on some flavors of Linux; your flavor of Linux might use “more”), PgUp and PgDn work, as does searching for text with the “/” key, or getting help on using less by pressing the “h” key. Exit by pressing the “q” key.