Questions tagged [command-line]
The command-line tag has no usage guidance.
43
questions
0
votes
1
answer
87
views
Cannot register a custom WP-CLI command
I am working on a custom plugin and one of it's functionailities is to scan all the posts/pages on daily basis and update a meta-data in the database.
I also wanted to create a custom WP-CLI command ...
2
votes
2
answers
1k
views
Bulk delete media by year
We have large media library with more than 300000 images.
We decide to delete all images < 2017 year manually using "FTP", from WP upload folder.
But after that in WP Admin > Media >...
1
vote
1
answer
978
views
WP Cli will not execute on Windows
I have tried to install Wordpress CLI on my windows machine running windows 10.
But for some reason everytime i try to run the
wp
Command it says
'sh' is not recognized as an internal or external ...
1
vote
2
answers
490
views
wp-env mysqlcheck error:1130
In Ubuntu 20.04 wp-env is giving me error once i have installed it and while trying to start it with wp-env start .The error showing is mysqlcheck: Got error: 1130: Host '172.29.0.5' is not allowed to ...
0
votes
2
answers
862
views
Carriage Return control character (^M) found in wp-config-sample.php
On a fresh WordPress install in Linux distributions, wp-config-sample.php contains Carriage Return control characters that are not found in any other .php file in the distribution.
Running
egrep -l $'\...
0
votes
1
answer
530
views
How to remove all plugins, posts, pages, and inactive themes in one line with wp-cli? WordPress bloatware removal
Softaculous seems to always adds junk to the installs I don't want. Such as example posts, pages, plugins, and starter themes. How do I remove them all for a fresh start?
1
vote
1
answer
116
views
How to retrieve text only from a post using WP CLI?
I have the post ids and urls. I need to extract the post content make some modifications and update again. I have more than 2,000 posts hence I would like to do it using WP CLI and not manually. Can I ...
3
votes
1
answer
862
views
How to change a post attribute to homepage using WP CLI?
I want to convert a page to homepage. To add widget to homepage I need to do that. How will I be able to do that using WP CLI?
0
votes
0
answers
466
views
bash script wp-cli search-replace 0 replacements, but command-line 3000+
I'm runnning this command;
sudo -u www-data wp search-replace www.siteurl.com www.newsiteurl.com --recurse-objects --skip-columns=guid --skip-tables=wp_users
From command line: 3.456 replacements
...
2
votes
2
answers
3k
views
wp search-replace returns no output on Multisite installation
I'm running multisite. Looking to replace old URLs with new URLs for pulling a copy of the site form one environment to another environment.
Here is my command:
wp search-replace --url=domain.com ...
2
votes
1
answer
1k
views
Find Wordpress root directory in bash without WP-CLI
How can I find the WordPress root directory in Bash without using WP-CLI?
1
vote
1
answer
1k
views
Shortest way to install WP-CLI
That's the shortest way I know to install the WordPress shell extension WP-CLI:
curl https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar > /usr/local/bin/wp && chmod +...
2
votes
2
answers
2k
views
How to disable XML-RPC from Linux command-line in a total way?
I read near the end of this guide regarding utilizing SSHguard to protect WordPress from Brute force attacks that after configuring SSHguard the relevant way, one must:
disable XML-RPC by blocking ...
1
vote
2
answers
3k
views
How can I list all installed plugins/themes/versions from CLI/API?
I would like to generate a simple text report for a Wordpress instance listing:
Wordpress version
plugins installed (version and whether enabled)
themes and child themes installed (version and ...
1
vote
2
answers
3k
views
How can I use PurifyCSS to clean WordPress style.css?
I am trying to use PurifyCSS to clean my style.css file. When I try it on static html file if works fine. See example of my CLI command:
purifycss wp01/wp-content/themes/mytheme/style.css index.html -...
1
vote
0
answers
358
views
Other than WP-CLI, is there a way to install Wordpress via the command-line?
I've been trying to create an Ansible playbook to install Wordpress. Most of the online documentation I've read, about installing Wordpress via the command-line points to WP-CLI. Question is, aside ...
2
votes
1
answer
1k
views
Error updating WP-CLI
Below is the output from my attempt to update wp-cli on Windows 10. Clearly another version is available. Can someone please explain how to make this work?
C:\Users\HP>wp cli update
Error: You can ...
0
votes
2
answers
550
views
wp-cli for Creating page-template
I've recently started using wp-cli to work on WordPress and starting to love it.
However, I'm curious about creating page templates using wp-cli. I haven't been able to find anything on it, does ...
4
votes
1
answer
849
views
Generate WP-CLI @alias for each site on multisite
I have a few multisites, each with several sites, that I want to auto-generate @aliases for. Is there way to sync those sites as aliases in my site list?
I'd like to be able to target a single site ...
1
vote
2
answers
886
views
Running custom defined WP-CLI commands without Wordpress installation present
I have registered custom commands that scaffording some files. These commands don't rely on any wordpress funcionality, basically outputs some files with content (what commands do is irrelevant in ...
5
votes
1
answer
2k
views
Where/how are categories stored?
Disclaimer: I am new to WordPress.
When I add categories to my blogging site, where/how are these categories stored? If I want to change the names of these categories in batch, without having to go ...
0
votes
1
answer
2k
views
Avoid 'uploads' 777 permissions: Potential threat or clean solution?
Recently changed hosting of a website and found the upload directory of WordPress wasn't "available". I have been reading that setting folder permissions to 777 would allow everything to work fine, ...
2
votes
2
answers
5k
views
How to run a php file that uses wordpress functions from command line?
I am using wordpress functions in a custom php file including wp-load.php, run from browser it is fine, but run from command line with php /path/.php wp-load.php causes problems:
Warning: Cannot ...
4
votes
2
answers
3k
views
How do I set and list page_template with wpcli?
I have a page that has a new template, and I want to set that new template with wp-cli.
When I wp post get <id> I get an output like the following:
+-----------------------+--------------------...
0
votes
1
answer
54
views
Trigger function without awaiting response?
I'm running an e-commerce solution for a client and have to upload a .txt file to an FTP for each order. I need to trigger the function I wrote to do this every time an order comes in, but I'm not ...
1
vote
1
answer
6k
views
Change Wordpress URL in sql file via Terminal
I've got a 40mb database file that I've exported from an old host and need to import it into a new host on a new domain. I normally open up the database in my code editor and find-replace, but as this ...
6
votes
2
answers
5k
views
Is it possible to export WordPress from command line?
Is it possible to export WordPress from command line?
I don't mean use mysqldump to export the database, but create the xml file used to easily import to another WordPress installation.
4
votes
1
answer
3k
views
How do I delete all generated images from my server except those currently used in posts
I have a new set of image sizes for my site's in-development theme. My server is filled with old image sizes, most of which have never been used. You've heard this one before, right?
The Question
How ...
0
votes
2
answers
2k
views
Database Update Required - Update from command-line
I just did upgrade my wordpress subtree of my website to the 3.6 branch and now the site tells me that I need to upgrade my database as well:
Database Update Required
Nothing special so far, just ...
5
votes
4
answers
3k
views
How do I pass an array as an argument to a WP-CLI command?
I want to use WP-CLI to create some new posts with custom taxonomy terms assigned. The challenge is that wp_insert_post's tax_input argument only accepts arrays, which I would have to specify on the ...
9
votes
4
answers
10k
views
wp-cli displays php notices when display errors off
I am using wp-cli and I am having php notices and errors show up when running wp-export. Some of these warnings and errors are ending up in the output file. How can I force errors to NOT show up. I ...
-1
votes
1
answer
2k
views
Why can't the WP-CLI installer find my php.ini?
I am trying to install WP-CLI on my Mac using the standard installation command (found here: http://wp-cli.org), yet I am receiving the following error message:
#!/usr/bin/env php
Some ...
32
votes
2
answers
19k
views
Initialize WordPress environment to use in command line script
I have a command line script for maintaining a wordpress plugin and have to load the wordpress core to be able to access wordpress functions.
This problem is very similar to Initialize WordPress ...
2
votes
1
answer
6k
views
How to determine wordpress base path when wordpress core is not loaded
I have a command line script for maintaining a wordpress plugin and have to determine the wordpress base path to be able to load the wordpress core.
I could just assume the script is several levels ...
8
votes
3
answers
22k
views
How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?
Normally, a MySQL database can be exported and imported using these simple SSH commands:
Export:
mysqldump -u USERNAME -p DATABASE_NAME > filename.sql
Import:
mysql -u USERNAME -p DATABASE_NAME ...
5
votes
3
answers
5k
views
How to use command 'wp post create' in wp-cli properly?
I need to create a single post with title, content and excerpt with this command as it's described in the utility documentation. Could you please show me an example of how to use it? I couldn't find ...
8
votes
2
answers
2k
views
Running WordPress on the Command Line - Turn off Delayed Output?
I'm creating a cron job that runs outside of WordPress. From a development perspective, this makes it really easy to debug and create cleanup scripts or cron jobs, by just running a command like the ...
1
vote
1
answer
6k
views
Run W3 Total Cache Flush Function with Crontab [closed]
Ok. I'm really stumped on this one.
Basically, I need to call a function for the Wordpress plugin W3 Total Cache as part of a cron job in crontab. I'd like to automatically clear the entire page ...
0
votes
2
answers
2k
views
Get plugin download URL from slug
Is there a way to take a plugin slug (e.g. 'akismet') of a plugin that is NOT currently installed and somehow retrieve the download URL of the current version (e.g. 'http://downloads.wordpress.org/...
3
votes
2
answers
5k
views
Initialize WordPress environment to use in a real cron script
I have to run a PHP script through real cron (WP cron being too unreliable). Within that script, I need $wpdb to insert data into WordPress table. But of course $wpdb will not be available as ...
2
votes
1
answer
81
views
Do you have to have command line access to use Subversion with Wordpress?
My group does not have command line access to the machine that is running our WordPress instance. However, we would still like to install/update using Subversion. Is this possible? Also, does ...
13
votes
4
answers
6k
views
Access WordPress API Outside of WordPress (command-line PHP)
I have a PHP script that I need to run as a cron job. However this script needs access to the WP API (get_pages(), get_post_meta() and get_permalink() specifically). I've followed the instructions ...
12
votes
6
answers
24k
views
Determining WordPress' Version from the Host's Command Line?
Given that I can't access the dashboard/admin pages on my blog (that's a future question), and that I have shell access to my hosting server, can I find out the current version of WordPress from the ...