I am trying to alter the query that's ran on the admin page of my custom post type. This page: /wp-admin/edit.php?post_type=my_venue. Typically, I would use is_admin() && is_post_type_archive('my_venue')
to check if I'm on the correct page before modifying the query. However, I have registered my post type with 'archive' => false
so now is_post_type_archive()
always returns false.
What's the best way to modify the query only for this page?
register_post_type(
'my_venue',
[
'has_archive' => false,
]
);
add_action('pre_get_posts', 'my_venue_filters');
function my_venue_filters($query) {
if (is_admin() && is_post_type_archive('my_venue')) {
if (!empty($_GET['my_venue_ids'])) {
$query->set('post__in', $_GET['my_venue_ids']);
}
}
}