I have a custom post type called pasakumi and for some reason in wp-admin the views (All / Published / Trash) are showing only 4 random posts, even though I have more than that. They're also not working, for example, 'Trash (1)' is showing the same 4 posts as 'All' (see gif below). If I create a new post, it just replaces one of the 4 shown.
The following is the code from functions.php I have for the custom post type. Maybe I need to change something here?
add_action( 'pre_get_posts', function ( $query ) {
if ( is_post_type_archive( 'pasakumi' ) && $query->is_main_query() ) {
$query->set( 'post_type', 'pasakumi' );
$query->set( 'post_status', array( 'future', 'publish' ) );
$query->set( 'orderby', 'date' );
$query->set( 'order', 'ASC' );
$query->set( 'posts_per_page', '-1' );
$query->set( 'date_query', array( array( 'after' => array( 'year' => date( 'Y' ), 'month' => date( 'n', strtotime('last month') ), ), ) ) );
}
} );
$args = [
"label" => __( "Pasākumi", "custom-post-type-ui" ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"delete_with_user" => false,
"show_in_rest" => true,
"rest_base" => "",
"rest_controller_class" => "WP_REST_Posts_Controller",
"has_archive" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"delete_with_user" => false,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => [ "slug" => "pasakumi", "with_front" => true ],
"query_var" => true,
"menu_position" => 4,
"menu_icon" => "dashicons-post-status",
"supports" => [ "title", "editor", "custom-fields" ],
];
Any help will be appreciated!
pre_get_posts
hook in there?