You need to call your custom file into your main plugin file. Without doing that, your custom file will not get called. Think of your main plugin file as your themes functions.php
file and your custom file like a custom file that also holds functions
By default, WordPress will only read your functions.php, and not your custom functions file. For wordpress to know to load that functions inside the custom file, you need to tell wordpress that there is a custom file with functions it should load. Normally, in a theme, you would use include
or require_once
. Here we would do the same, except, your path will differ from themes
So you can try the following in your main plugin file
require_once(dirname(__FILE__) . '/testhook.php');
Related Posts:
- How to add a javascript snippet to the footer that requires jQuery
- Enhance Media Manager for Gallery
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- How to create an API for my plugin?
- Plugins in symlinked directories?
- How to use PanelColorSettings in custom Gutenberg block?
- Is there a way for a plug-in to get it’s own version number?
- How to add tab which is visible only in admin side of product in woocommerce? [closed]
- How do I print a notice only on certain admin pages?
- Hook the Keydown Event in the TinyMCE Post Editor
- Create a clickable name in WP_List_Table for Plugin Admin
- Plugin development without Theme adjustments?
- How to Make a Category Always Selected?
- Unable to write test cases for a WordPress plugin using PHPUnit and WP-CLI
- WordPress Settings API: saving multiple rows of similar data
- Modify how gallery.js builds the shortcode [gallery ...] in tinyMCE?
- How to use is_multisite() in a must-use-plugin?
- Can’t we use strings defined as PHP constants if we want to translate them in a plugin?
- why creating tables using $wpdb is not being executed while installing plugins?
- How to update the language used by wordpress from a plugin
- DataBase connection problem with PHPUnit and WordPress
- Modify a Free Plugin available on wordpress.org & include with my Premium Theme? [closed]
- Using wp_filesystem in Plugins to store customizer settings
- Plugin settings not saving
- How do I write a shortcode that opens and closes?
- Registering and using actions which return results in a Plugin class
- Plugin developement and SVN
- How to replicate Media Library “Add New” on Plugin Settings Page
- WooCommerce Conditional Tag inside plugin
- Plugin writing: access file that was just uploaded
- Add code inside specific wordpress standard function
- Conditional hook based on the core function that is calling it
- Best way to save custom css for an block
- How to hook a custom user function to a wordpress core ajax action?
- How to change the hover content of a specific menu item on WordPress?
- PHP – Extend WordPress Woocommerce Revenue Analytics with custom field
- Amending REST API function without deactivate/activate plugin every time changes is made
- How can I listen to events in Gutenberg block?
- Plugin callback page
- Is nonce in PHP form and Ajax both necessary?
- How to add WordPress Admin “Insert Link” UI (searches through existing posts for URL) and functionality into a custom plugin?
- Unable to change footer using wp_footer action hook
- Input in plugin widget does not allow spaces
- Admin Posts List (edit.php) by post IDs
- White screen when activating plugin that sends form via WordPress
- dbDelta SQL Query Not Working
- wp_localize_script is not adding a global variable for javascript
- wp_get_theme Warning: Illegal offset type
- wordpress is adding a second backslash when I use addslashes
- Silently register plugin pages
- A question about add_action()
- How to add a hyperlink to the email content in WordPress?
- Menu page with minimum capability as ‘Subscriber’ doesn’t allow ‘Admin’ to access it?
- How to display the categories on page using shortcode?
- How to Get Rid of Unwanted Backslashes in WordPress Form Input inside admin menu option
- Pass CF7 form data to plugin
- WordPress plugin cron working only if admin is logged in
- How to Customize Polylang Language Items
- WP Dropdown Categories, display subcategories but not grandchildren categories?
- Ajax +wordpress onClick link redirect to new page and create html content
- Adding filter to the title without affecting the menu title
- How to show multiple instances of the WP125 Widget?
- How can the_excerpt (or equivalent) be called on a category description?
- Plugin Creation: Overriding upload_max_size and post_max_size
- Problems with wierd characters and my plugin
- How to call a function from a shortcode function in an oop plugin
- How to access index file in Block Themes?
- wp_new_user_notifications to notify user and admin about new user registration
- Posts form with AJAX request – Plugin development
- Multiple TinyMCE on button click is initialized and appended but why only last one is writeable?
- How to create a custom post-new.php page for plugin , no wp menu
- How to create a custom WordPress page with my plugin?
- Want to know how to reveal a WordPress theme, considering the theme name is hidden?
- Where to add functions and code snippets in wordpress
- How to re-render inspector controls?
- Why User_login key doesn’t work with wp_update_user()
- Sanitize WordPress Array Input?
- How to limit number of category term display in home page grids?
- WC REST API Error Handling
- Shortcode content is not showing. Only the [shortcode-tag] is showing
- How to remove the WooCommerce Product->Category thumbnail from admin [closed]
- Is it possible to replace MySQL with JSON files for WordPress
- Creating a virtual page without exit
- Plugin Development – Call to undefined function comment_exists()
- Replace “content-area” of themes 404 page with plugin?
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- WordPress doesn’t create table on plugin activation
- Create Customization panel for Plugins not for theme
- How is construct function working even when variable is assigned null value?
- Allow user to change homepage
- Custom signature appears twice on page
- Declaring a new woo commerce product type i get this error
- wp_mail links are dead
- List Available Templates for Current Theme in a Plugin
- Adding Third Post Box Column: postbox-container-3
- Get custom wp_query search results to appear on search.php
- Is it safe to use PUT and DELETE requests
- WooCommerce custom payment gateway
- Multi-part form and wp_redirect()
- Sharing changes to a post (preview changes) with another user