Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions features/post.feature
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,18 @@ Feature: Manage WordPress posts
| Publish post | publish-post | publish |
| Sample Page | sample-page | publish |

When I run `wp post create --post_title='old post' --post_date='2023-01-24T09:52:00.000Z'`
And I run `wp post create --post_title='new post' --post_date='2025-01-24T09:52:00.000Z'`
And I run `wp post list --field=post_title --date_query='{"before":{"year":"2024"}}'`
Then STDOUT should contain:
"""
old post
"""
And STDOUT should not contain:
"""
new post
"""

Scenario: Update categories on a post
When I run `wp term create category "Test Category" --porcelain`
Then save STDOUT as {TERM_ID}
Expand Down
8 changes: 5 additions & 3 deletions src/Post_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,14 @@ protected function delete_callback( $post_id, $assoc_args ) {
public function list_( $args, $assoc_args ) {
$formatter = $this->get_formatter( $assoc_args );

$defaults = [
$defaults = [
'posts_per_page' => -1,
'post_status' => 'any',
];
$query_args = array_merge( $defaults, $assoc_args );
$query_args = self::process_csv_arguments_to_arrays( $query_args );
$array_arguments = [ 'date_query' ];
$assoc_args = Utils\parse_shell_arrays( $assoc_args, $array_arguments );
$query_args = array_merge( $defaults, $assoc_args );
$query_args = self::process_csv_arguments_to_arrays( $query_args );
if ( isset( $query_args['post_type'] ) && 'any' !== $query_args['post_type'] ) {
$query_args['post_type'] = explode( ',', $query_args['post_type'] );
}
Expand Down