Delete unused images in WordPress using WP CLI - Delete unused images in WordPress using WP CLI

Delete unused images in WordPress using WP CLI

This small script uses a for loop to delete one post ID at a time, it will go through the database and list all media files uploaded in the provided data range that are not used inside posts. Change the date range according to your needs.

Delete Expired WordPress Transients - Delete Expired WordPress Transients 🚮

Delete Expired WordPress Transients 🚮

WordPress uses transients to temporarily store data for its plugins and themes. By managing transients you can optimize your website for speed and make sure your website is always functioning properly. Here are a few methods how to safely delete expired WordPress transients: Delete Expired WordPress Transients using WPCLI To delete only expired transients use: … Read full article →

WordPress hooks tutorial - WordPress hooks tutorial

WordPress hooks tutorial

WordPress hooks are a powerful feature that allows you to customize and extend the functionality of your WordPress website without modifying the core code. They are essentialy points in the WordPress code where you can add your own custom code or functions. There are two types of hooks in WordPress: actions and filters. Action hooks … Read full article →

How to Create a WordPress Child Theme - How to Create a WordPress Child Theme

How to Create a WordPress Child Theme

60 seconds or less, that’s all that takes to create a WordPress child theme and I highly recommend that you do it before even thinking about making any code or style modifications to your active theme. There are two files that you can use inside a child theme to overwrite parent theme’s functionality or style: … Read full article →

How to Show Different Themes to Logged in Users in WordPress - How to Show Different Themes to Logged-in Users in WordPress

How to Show Different Themes to Logged-in Users in WordPress

In this example, we’ll use the is_user_logged_in() to display a different theme on our website for visitors: if(is_user_logged_in()) { function wpxss_set_my_custom_theme() { //replace your theme name here return ‘your-theme-name’; } add_filter( ‘template’, ‘wpxss_set_my_custom_theme’ ); add_filter( ‘stylesheet’, ‘wpxss_set_my_custom_theme’ ); } else { // leave the default theme active for visitors } The template and stylesheet filters are responsible to select the activated … Read full article →

wpcli w3tc - Purge cache from W3 Total Cache plugin using WP-CLI

Purge cache from W3 Total Cache plugin using WP-CLI

Here are some useful commands to clear cache from the terminal with wpcli: cdn_purge purge URLs from CDN and Varnish flush all flushes all cache related to W3TC (Page Cache, OC, DB Cache, Minify, etc.) flush page flushes pages cache only flush posts flushes both pages & posts cache flush database flushes DB cache flush … Read full article →

Optimize WordPress Database Tables - Optimize WordPress Database Tables

Optimize WordPress Database Tables

There are several ways you can optimize the MySQL database used by your WordPress site: Optimize tables Optimize all tables in your database: OPTIMIZE TABLE wp_posts, wp_comments, wp_options, wp_usermeta, wp_term_relationships, wp_term_taxonomy, wp_termmeta; Replace wp_ with the database prefix that you are using for your WordPress installation. Repair tables Repair any damaged tables in your database: … Read full article →