You should use the load-edit.php
action hook, and check for your post type (untested):
add_action( 'load-edit.php', static function () {
$screen = get_current_screen();
if ( empty( $screen->post_type ) || 'myposttype' !== $screen->post_type ) {
return;
}
new the_function();
} );
You could also use the current_screen
hook, but load-edit.php
seems more correct.
Related Posts:
- What are the differences between WPINC and ABSPATH?
- Using require_once in a Plugin?
- Making plugin unique to not conflict with plugins with the same name
- How to find out if option exists but is empty?
- Errors while using ajax from external wordpress page
- shortcode doesn’t work
- send_headers don’t work on wordpress multisite
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- Scope for PHP Variables Assigned in functions.php or a plugin
- Plugin Development sqlite or WordPress’ database
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- Where should I save an API key of my user when installing my plugin?
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- WP Post Template – Templates in own folder
- Avoid class name collision when using third party libraries in plugins?
- wordpress plugin is not activating from widget
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Image upload and download from front-end
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- What are the specifics of WordPress development I need to know? [closed]
- Ajax call returning 0
- WP All Import – Execute Imports
- How to replace WordPress Media Upload Window with user’s device window?
- Conditional attributes and logic per product category
- How to create a custom post type that contains another custom post type?
- Setup wp_schedule_event within a custom plugin
- Check if variable is set in filter
- Issue running db create table query from static method
- execute function after one completed
- How to make multiple admin pages for one plugin?
- Include a php file from another plugin
- Integrating boxtal PHP library into a custom WordPress Plugin
- How to create plugin/ page that reads from database
- Save user total active time after login in wordpress [closed]
- Switch from wp-cron to a server cron job
- Why is it important to check for isset and is_array before checking in_array in this example?
- How to add/change (woocommerce) product tab icon
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- I want to generate the pdf and save it in library?
- Calling a save function from a “submit” button
- Wp Debug Enabled True Notices and Warning
- How to call external functions from a PHP script in a WordPress plugin?
- How to write to a separate PHP file in plugin settings
- Create “new pages” within the admin section of plugin
- More gentle way to hook WordPress custom url
- How to display results from a data table with an encrypted user id?
- How to add custom function to pluggable.php
- How to displaying Custom image, text and default image logo from Redux Framework option panel
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- How to Add text value in Automatically in this conditions?
- Checkbox show / hide output result
- save_post_product action not firing
- How to get the custom field value using SQL query
- Unexpected add action function in WP plugin
- admin_notices show after load completed
- Prevent WordPress from sending set-cookie http header
- Cookie value changes back to previous value after changing
- How use wp_insert_post and add og:custom tags?
- Is there any way to sync Facebook Comments and with comments on WordPress website?
- Hide content for specific users with id
- adding dynamic/multiple slug values in ‘option_none_value’
- WordPress rewrite rule depend on meta values not ids
- How to change “Read More” text?
- How can I see $post object in frontend from functions.php?
- Move plugin pages from dashboard to front-end
- Problem with wordpress has_action() function
- Offering a freemium plugin (a free version + paid version)
- Using id to show item
- 500 Internal server error wp_handle_upload_prefilter
- Can’t access 3rd party API, code works on local server but not on wordpress
- Generate and send ICS file through WordPress
- Get post content inside plugin class method
- Is admin section completely customizable in terms of styling?
- Change pricing in Woocommerce based on Category and Product [closed]
- WordPress environment not loading properly
- WordPress not displaying information on post sent from custom admin form
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Creating a user ‘add custom field’ section
- Autoloading a PHP class – working outside, but not inside WordPress plugin
- Saving an array to get_options
- Saving plugin data returns “You do not have sufficient permissions to access this page.”
- How to add a handler for a button in plugin?
- Doing action based on input from options menu
- Help me with my first very basic plugin
- Load my plugin before cache
- How use Dynamic hyperlink on each wordpress post?
- My wordpress website admin panel loads very slow, what can i do about that? [closed]
- wordpress select multiple options and illegal string offset ‘timeslot’ [closed]
- How to create post comparison in wordpress
- Function not being called on form submit, only blank admin-post.php page
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- WordPress Throwing Deprecated Errors on its own Files
- public custom posts not showing in my wordpress plugin
- plugin doesn’t retrieve data from database
- REST API – filters not working inside plugin class