I checked the docs and the wp gf entry delete
only supports id lists, even though it supports inline listing like wp gf entry list 1 --status=trash --format=ids
, there’s no parameter like start_date
or end_date
, which makes deleting entries in a date range impossible. Is there a way to do it as I have over 10k entries so I cannot handle it in admin dashboard.
Hello @michaeledi - the listing of entries and the exporting of entries in the command line is the same as it is in the WordPress admin dashboard. You can’t show entries based on a start and end date, and the start and end date options are only available on export.
I think you will need to do this in two steps using the CLI:
- export the entries to a csv file using the
--start_date
and--end_date
parameters - read the entry IDs from that csv file into your
wp gf entry delete
command
I tried for a little bit to get this exactly right, but could only come up with a hacky method the relied upon me knowing which column in the CSV contains the entry ID. Someone with better shell skills could definitely make this happen. I will leave this open in case someone can add their own thoughts or approach. Thank you.
For reference, here is the clunky method I came up with.
- Export the entries to a file:
wp gf entry export 198 --start_date=21-01-01 --end_date=21-03-31 out.csv
The exported entries for form 198 from Jan 1, 2021 to Mar 31, 2021 to a file out.csv
-
Figure out which column contains the entry ID by viewing the header line of the CSV. In my case, the entry ID was in column 9.
-
I used this command to trash the entries IDs I found in the CSV file:
wp gf entry delete $(awk -F "," '{print $9}' out.csv|sed 's/[^[:digit:]]\+//g'|paste -d\ -s)
You can force the entries to be deleted rather than being put into trash. And you probably want to verify that the export is working as expected, before you try to delete thousands of entries. If you have any other questions, please drop them here. Thank you.
Hi Chris,
Thanks a lot for the solution, I will look into it
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.