The command line for WordPress: the commands used most often, safe search-replace after migrations, database dumps, running cron, managing a Multisite network, and writing your own commands.
Create and update posts in code with wp_insert_post() wp_insert_post() and wp_update_post() create and change posts without the editor: in import scripts, WP-CLI commands, plugin activation (a default page), or a cron job that pulls content from an API. They take an array with the columns of the posts table and two helpers, meta_input and tax_input,…
Control post revisions: WP_POST_REVISIONS, filters and cleanup Every time a post is updated, WordPress saves the previous version as a revision: a row in the posts table with post_type = 'revision' and the post as its parent. Revisions are a good safety net, but without a limit they pile up. A site with a few…
How to find the login page when the WPS Hide Login plugin is used An unpleasant situation: you type /wp-admin/ or /wp-login.php to get into the dashboard, and you are redirected to some page, but not to the login form. Usually the default login page is hidden for one purpose, security: bots cannot brute-force the…
Replace a string in the whole WordPress database Sometimes, because of a company rebranding or simple inattention, a string has to be replaced everywhere on the site, or a symbol added to a word. In my case “Company Name” had to become “Company Name®”. Traditionally, there are several ways to do it.