You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To fetch all posts from 2015, command should be similar to wp post list --post_type=post --format=ids --year=2015
Currently query parameters are directly merged with default and passed to the WP_Query call. https://github.com/wp-cli/wp-cli/blob/master/php/commands/post.php#L351 I doubt such type of query is currently possible. May be we can introduce some kind of mechanism where list command accepts multi level query parameters.
wp post list --post_type=post --format=ids --date_query='{"before":{"year":"2015"}}'
Just one noob idea :D
Then we can support meta_query and tax_query in similar way.
Or will this be too much for a single command?
Reacted by Pothi Kalimuthu, Leho Kraav, Alejandro A. Medina, yuvilio and Mauricio Gelves
I doubt such type of query is currently possible. May be we can introduce some kind of mechanism where list command accepts multi level query parameters.
I've considered this in the past, but never identified a syntax I thought worked well.
So what I would like to do is not possible with wp-cli but is possible with wp-rest-cli?
Yes:
wp rest post list --after="2014-12-31T23:59:59" --before="2016-01-01T00:00:00"
just to save other people seeing this solution time, wp rest post list is only capable of returning 100 post results at a time... it was more efficient for me to run wp post list --year queries for each year's worth of posts i needed to modify.
So what I would like to do is not possible with wp-cli but is possible with wp-rest-cli?
Yes:
wp rest post list --after="2014-12-31T23:59:59" --before="2016-01-01T00:00:00"
just to save other people seeing this solution time, wp rest post list is only capable of returning 100 post results at a time... it was more efficient for me to run wp post list --year queries for each year's worth of posts i needed to modify.
Pagination makes sense for a network api but for a cli that passes off a ton of complexity onto the user.
Reacted by Guido Pettinari, Jake Snyder and Philipp Bammes
Since it's been 6 years and there hasn't been active development of wp-rest-cli in the last couple years, so is wp-cli still the more appropriate place for this to be solved?
Activity
ernilambar commentedon Jun 20, 2016
To fetch all posts from 2015, command should be similar to
wp post list --post_type=post --format=ids --year=2015Currently query parameters are directly merged with default and passed to the WP_Query call. https://github.com/wp-cli/wp-cli/blob/master/php/commands/post.php#L351 I doubt such type of query is currently possible. May be we can introduce some kind of mechanism where list command accepts multi level query parameters.
wp post list --post_type=post --format=ids --date_query='{"before":{"year":"2015"}}'Just one noob idea :D
Then we can support
meta_queryandtax_queryin similar way.Or will this be too much for a single command?
danielbachhuber commentedon Jun 20, 2016
I've considered this in the past, but never identified a syntax I thought worked well.
The future of
wp post listiswp rest post list, so I don't think we need to solve the problem here https://github.com/danielbachhuber/wp-rest-cligrappler commentedon Jun 20, 2016
@danielbachhuber So what I would like to do is not possible with
wp-clibut is possible withwp-rest-cli?danielbachhuber commentedon Jun 20, 2016
Yes:
tmuka commentedon Feb 14, 2019
just to save other people seeing this solution time,
wp rest post listis only capable of returning 100 post results at a time... it was more efficient for me to runwp post list --yearqueries for each year's worth of posts i needed to modify.formido commentedon Feb 4, 2021
Pagination makes sense for a network api but for a cli that passes off a ton of complexity onto the user.
davidsword commentedon Nov 29, 2023
I used this hacky snippet to get the
--date_query='[{"after":"7 day ago"}]'to work in wp cli for a site I needed it on:skorasaurus commentedon Nov 22, 2024
Since it's been 6 years and there hasn't been active development of wp-rest-cli in the last couple years, so is wp-cli still the more appropriate place for this to be solved?
If so, looks like this is blocked by #4616
skorasaurus commentedon Feb 18, 2025
appears that this is now implemented! wp-cli/entity-command#520