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:
- Filter by custom field in custom post type on admin page
- How can I remove the “Add New” button in my custom post type?
- How to remove Filters from post admin page?
- Adding a drag and drop re-ordering from a custom post type default list [closed]
- How can I filter posts by post_parent in the admin?
- $query->set in pre_get_posts is unintentionally affecting the backend
- 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?
- Add Custom Post Type to Current Query
- 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
- WP Admin default view mode for Custom Post Type
- Remove wpautop from all posts/pages except my custom post type
- Remove date and category filters when editing custom post types
- Pre_get_posts Gives 404 on Custom Post Type
- Taxonomy terms with edit/filter link in wp-admin, in the list of custom posts
- Make the ‘all’ filter default instead of ‘mine’ in a custom post type
- Exclude custom function content from certain pages
- filter search result with custom post type meta key
- Order posts by (hierarchical custom) taxonomy terms and term children
- Filter get_categories() for taxonomy term in WordPress
- Debug output during filter execution doesn’t work
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Multiple post types in archives (filter?)
- Unable to filter on field on edit.php page
- Can’t sort order of wp_query with 2 meta keys
- Highlight nav menu terms
- Want to filter only parent post in admin area
- Adding posts of custom type into the main feed
- Filters post in admin with dropdown select, custom post type
- Admin List Dynamic Heading
- What is better: Custom Fields vs Custom Taxonomies with Terms for perfomance, scalability and better user experience
- Display all Posts and only certain Custom Post Types with meta fields
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Add $more_link_text parameter to the_excerpt()
- Custom Taxonomy breaking pages permalinks
- Issue with pre_get_posts on custom post type archive pages
- Add html to cpt main page / admin edit.php
- How to sort custom post type posts in default order by multiple fields?
- register_taxonomy and register_post_type does not work [closed]
- Custom post type show on both Home and Date Archive
- Filter categories of posts with checkboxes
- pre_get_posts on custom post type
- WooCommerce product search titles only
- Custom query to filter posts that have current post as a taxonomy [closed]
- Setting proper query for multiple custom admin filters
- How to query custom post types posts filtered by multiple custom taxonomies through a form selection
- How to modify archive query with pre_get_posts to append CPTs?
- Genesis filterable portfolio isotope [closed]
- How can I see a list of my Custom Post Types of the last term I was in?
- Multiple meta_values in the pre_get_posts filter?
- Custom post type search using $_SESSION and pre_get_posts
- Categories of custom taxonomy don’t show any posts
- How to add a post slug to a url?
- How to filter wp_list_categories output with some custom post type meta query?
- How to Filter custom post type by taxonomy?
- creat filter with wp_query
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- Filter hierarchical custom post type admin page by parent, and include children & grandchildren
- Versioned Custom Post Type (Not the same as revisions)
- Filter Posts from the Main Query
- Categories filtering in new post
- wordpress remove views from action links in a custom post
- Main menu not appearing in custom post type archive
- Filter posts by tax (dropdown) and meta value
- sortable columns for multiple custom post types not working
- I need to add a filter to prepend the term ‘National – ‘ to the post title if the post is tagged to multiple states
- Prevent A Specific Custom Post Type Showing In WP Search Results Page
- pre_get_posts works in post type archive but not in single post
- Catch and display error on save_post action
- Is possible register two archive pages for single custom post type?
- Display custom post front end filter by ACF equals current user
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- Best way to fix bad count on All | Mine | Published
- Query to Exclude Child Pages from Custom Post Type Archive
- How do I troubleshoot pre_get_posts with Debug Bar?
- Create Post Types from a XML url (Real Estate website)
- Display Specific Posts at Start of Loop
- How to use multiple orderby conditions on query search results? (orderby one post type, relevance)
- List all posts associated under custom taxonomy
- Keep br tags from stripping
- What’s the most efficient way to get two queries based on an if statement?
- Add filter button to custom post type in admin area
- Adding Information To All Posts Screen
- Filter Content on all Post Types
- pre_get_posts with multiple post types AND a meta_key
- Sorting on Taxonomy in archive page
- Custom Search Template for Custom Post Types
- Fetch post meta in the same query as the main loop
- Problem to show custom post type in archive page category wise
- Using $seed on a custom post type for randomly displayed posts
- How do I sort post listing by child post count?
- Rewrite a filter as shortcode (or something like that) to use anywhere in CPT
- add_filter > posts_where works partially
- When Attempting to Filter Plugin Generated Content Using Filter post_type_link, Permalinks Are Not Modified
- Change CPT Edit Target Link for Admin List
- Add Custom Taxonomy Terms as CSS Classes for CPT Posts in an Elementor Loop Item Template
- coloring row’s background based on custom field value