There is a built-in function that you can use, instead of globals. The get_current_screen()
function allows you to get the information associated with the current page.
One of its return values is post_type
. So you can check against an array of post types to see if anyone matches.
function fhaac_admin_enqueue_scripts(){
$screen = get_current_screen();
if (
in_array( $screen->post_type, array('fhaac','blabla')) &&
$screen->base == 'post'
) { // Do something }
}
Related Posts:
- How to enqueue scripts on custom post add/edit pages?
- Load a script just to custom post type in admin
- Style custom columns in admin panels (especially to adjust column cell widths)
- How to localize value of posts
- Trying to add script to specific admin page is not working
- if custom posts type exists and there are posts load script
- custom fields cannt be seen with version 3.1
- One Site. One Theme. Multiple Stylesheets without plugins?
- Enqueueing TinyMCE
- Use conditionals with wp_enqueue_style to attach stylesheet according to post type displayed
- Loading a stylesheet on a specific page [duplicate]
- How to make sure, that only the selected post is changing?
- Marking future dated post as published
- Custom Taxonomy as checkbox or dropdown
- how to group custom post types
- Page as child in custom post type slug?
- How to quickly switch custom post type singular template?
- Post metadata deletes itself
- Get latest 4 post on a custom post filtered by category
- How can you use custom types/taxonomies? [closed]
- Get child terms of current term of the current post
- Allow duplicate slugs for posts on Custom post type in different categories/taxonomy?
- Assign category to front end post
- Remove Post Page “View Post” Link
- WordPress Template Hierarchy
- Taxonomy structure of Sport site
- How can I add a column in the wp_list_table of the admin area?
- How does the $post_type global variable work?
- how to check if custom post type exists in wordpress
- Custom post type custom taxonomy archive page name
- Archive slider for CPT
- Custom Page that comes with preloaded content for the user
- Automatically update custom field in all posts of a custom post type
- Custom post type not showing in admin menu
- List children on child post
- Multiple TinyMCE editors in dynamically generated textareas
- How can I set taxonomy programmatically
- Return the latest post from a custom Taxonomy and Post Type
- Don’t know how to show custom taxonomies from a custom post_type
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- post meta parameter in post custom-post-type endpoint with restapi
- Adding sidebar to template creates horizontal gap the size of the side bar
- Filter custom posts by multiple taxonomies
- Create a Custom Post from within another Custom Post
- Add update or delete database records using custom post type
- Featured image in CPT overview column
- Event Custom Post Type Title show by upcoming Event Dates
- How to group posts and get a mixed posts and groups view?
- How to show featured image block in custom post type for Author?
- dropdowboxes with pre-selected custom fields optios that filters the results according seach needs
- Display Repeatable Meta Box Content
- Control content before and after custom post type loop
- Showing custom post type categories in the menu
- Convert comma separated list to serialized array to import as post meta
- Problem with Apply Filters on URL in meta box filed of custom port type
- WordPress rewrite url
- add pagination to custom category posts
- How to create object in wordpress?
- Improve Custom Post Permalink Structure
- Modifying Dashboard edit.php
- How to import database table as custom post type and custom fields?
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Creating custom post type and taxonomy archives and pretty URLs
- How do I add multiple post types to this query?
- Using custom post type as front home page pagination not working
- Migrate Custom Post Type with Custom Fields data and parent child order
- Archive page for WordPress Custom Post Type doesn’t show pagination from paginate_links()
- How to create review point system for CPTs (many-to-many relationship)
- Search for custom field input of a custom post type in ajax live search
- Register custom_post_type from static function
- WordPress custom post type as homepage with homepage url
- Custom post type single page returns 404
- How to select meta key in custom database query
- localize_script or rest api
- WP_Query with all posts in one custom post type and only posts in another custom post type with a specific category
- Add content to wordpress edit.php page
- Search result based on URL
- Show posts under a selected custom taxonomy term
- Widget area for individual posts (custom post type)?
- Linking Taxonomies
- Custom Post Type with Subfolder in Custom Theme
- Link two different post using there post_id in post meta
- How do I extract the contents of a CPT’s custom field for all posts?
- Get number of posts by a user (draft, pending review & published)
- How can I generate a list of post-type specific categories?
- Publish post and create additional posts with same content
- Excert ( the_excerpt(); ) Not working properly
- Keep same archive.php for post from archive?
- Use one template for different custom post types with the same markup
- Events with multiple event dates + permalink for each date
- After rewriting post type’s URL, the number of queries has increased dramatically
- Custom field totals
- Pagination not working on homepage
- How to query custom post then display sections by meta value
- Prevent users from changing post status
- How do I paginate a custom post type listing on a custom template page?
- A to Z list for custom post types
- What Is My Fault With This WP_QUERY ? [ Pagination Problem ]
- get_the_post_navigation not working
- Sort ACF by custom taxonomy