The function you are looking for is get_current_screen(). To check if you are on a specific custom post type page, do as follows:
$screen = get_current_screen();
if ( $screen->post_type == 'custom_job' ) {
// We are on custom_job post type, good to go
}
Now, if you visit edit.php?post_type=custom_job, this conditional will return true, which you can set your query inside.
There is also another approach for this. By using is_post_type_archive('custom_job'), you can target the edit.php?post_type=custom_job. Make sure you use this in conjunction with is_admin() to make sure you don’t target the front-end.
Related Posts:
- How can I remove the “Add New” button in my custom post type?
- Media library – Limit images to custom post type
- How to remove Filters from post admin page?
- Custom sortable columns ordered by meta-value?
- How do I filter the excerpt metabox description in admin?
- How do I Filter Custom Post Type by Custom Taxonomy in the newest WordPress RESTful API?
- Filter for “get_post_type_archive_link()”
- How to show more posts on an archive page?
- Include post id[s] into WP_Query()
- Pre get posts for single post
- Filter by custom Field for Custom post type Admin Listing
- How to get my Custom Post Type to display in Recent Posts using “pre_get_posts”
- Remove wpautop from all posts/pages except my custom post type
- Remove date and category filters when editing custom post types
- filter search result with custom post type meta key
- Multiple post types in archives (filter?)
- wp_query and comment_parent – select only posts with top level comments
- Displaying custom post type on category pages but not on blog listings
- Highlight nav menu terms
- Want to filter only parent post in admin area
- Custom post type with tags
- pre get posts changing the query
- Filters post in admin with dropdown select, custom post type
- How can I add a column in the wp_list_table of the admin area?
- How to filter the description of a custom post type
- Filter home_url for custom post type
- Add Content Exclusively to a Custom Post Type Feed
- Issue with pre_get_posts on custom post type archive pages
- Add html to cpt main page / admin edit.php
- register_taxonomy and register_post_type does not work [closed]
- pre_get_posts on custom post type
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- Multiple meta_values in the pre_get_posts filter?
- How to Filter custom post type by taxonomy?
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- How to change the post type a theme shows by default?
- filter custom post in rest api with custom function
- Filter hierarchical custom post type admin page by parent, and include children & grandchildren
- Sort and filter custom post type posts by custom taxonomy
- the_content filter on some post types only not working
- Custom filter function not working with Custom post type
- Filter Posts from the Main Query
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- How does the filter post_updated_messages work?
- How to order posts of a custom post type by date DESC in dashboard Admin?
- Is there any way to get list of all possible filter hooks for all post types?
- Can I display custom post types in home.php or need page template?
- Create new custom post and post category of same name
- wp_insert_post wrong post type [closed]
- Excluding a Custom Post Type with a specific tag using pre_get_posts
- how to show records that don’t have custom meta value
- How do I add custom HTML to the content of an archive page’s posts?
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- REST filters only firing when I have a param set
- How to query for posts (hierarchical custom post type) that have children but are NOT top level?
- CPT Archive pre_get_posts not working?
- How do I show a link or ‘Read More’ button on a custom field excerpt when it is less than the word limit
- How to filter url on post submission?
- Filtering the_content, but still need to display the unfiltered content inside filter
- Custom Taxonomy Filter Issues
- Remove filter and view options from custom post type edit screen
- custom filtering admin columns
- Ajax Post Filter | Split Taxonomy Into minPrice & maxPrice
- Order posts by taxonomy terms
- Query filter by value in meta_value array
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- Is there any filter to add a custom attribute to the tag in admin panel?
- Dynamic page for nav items used as filters
- Filter posts by their related field’s custom field
- Post Click Redirect to Custom URL instead of Single Post Page
- How to hide private posts even if user is admin
- Output all terms slugs for a loop filter
- Help Adding filter to Add Media button for custom post type
- Set different posts_per_page for custom post type/taxonomy
- CPT year wise archive based on custom date Field
- how it’s possible to show from a post of a custom post type the taxonomy/terms?
- Meta query broken since 4.7.4 Update
- Enable shortcodes on custom post type
- Filter between Custom Posts depending on meta_value
- Creating adminable dynamic filtering on custom post type
- Pre_get_posts comparison with custom field doesn’t work
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- Custom Post Search
- Filter wp_dropdown_categories Per Post Type
- add current-menu-item to multiple custom post types
- using ACF datepicker to filter posts on a page
- Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
- Restrict a filter to a custom post type. Am I doing this right?
- pre_get_posts action doesn’t work
- custom post types, pre_get_posts, wp_list_categories
- Simple Share Buttons Add Plugin and Custom Post Type
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- When Attempting to Filter Plugin Generated Content Using Filter post_type_link, Permalinks Are Not Modified
- Sorting by Title for Post Archive Categories for Custom Post Type
- Add Custom Taxonomy Terms as CSS Classes for CPT Posts in an Elementor Loop Item Template
- How can I incldue a “private” post type in a loop for public users?
- Add post id to url instead of WordPress default -2 suffix
- Search for portfolio tags & mixing portfoliotags and post tags
- Modify wp_title for custom post types using custom fields data?
- How to set up a private custom post type that is accessible in the administrative dashboard?