Your function needs 2 arguments, but you didn’t mention this to add_action
add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )
https://developer.wordpress.org/reference/functions/add_action/
By only passing the tag and function to add, PHP used the defaults for priority and accepted arguments, which were a priority of 10, and 1 accepted argument. But 1 != 2.
So, to fix this, you need to specify the accepted arguments parameter
Related Posts:
- Missing feature image link function
- How to customize the_archive_title()?
- Get menu object from theme_location
- Displaying the number of updates available in the Admin area
- Trying to use add_action and do_action with parameters
- How to change the markup WordPress inserts for post images
- When tax_query used, results disappear (0 =1 produced)
- Safe to disable wptexturize?
- Get a list of all available fields in the User Profile
- Targeting specific menu with wp_nav_menu_items
- wp_get_attachment_image returns different image size
- Insert Ad Code in the Middle of a Post
- Limit the length of the Author Profile Biographical Text
- Add options to featured image
- disable comments if array exists
- WordPress Change Post Templates,but not drop down, but Image selection
- Programmatically Add Font-Awesome Icons to Category Widget
- Remove images from get_the_excerpt
- Remove “says” from comments
- Reuse variable in hook callback
- Dynamically Register Sidebars For Each Top Level Page
- Logging in redirects to correct page but shows logged out content until forced refresh
- Run Product Filter Javascript On Page Template
- I changed “Howdy” in the admin bar in the dashboard, but when I’m viewing the site it still says Howdy!
- Template tags vs get_template_part() vs functions.php
- Changes to functions.php not working
- Custom excerpt legnths for specific pages
- Custom logo sizes for multiple logos
- How to Add a Random Custom Gravatar in the WordPress Comments?
- how to change link of some wordpress pages
- Add custom image size not working
- When to use an if statement after get_posts?
- Programmatically Create Category and sub Category
- How to mass-delete inline styles in WordPress custom post type automatically?
- Include files in child themes, declare in functions.php
- wp_get_attachment_image function size argument not working if I also add a custom class
- Display first name of logged in user?
- functions.php mistakenly deleted
- Identical custom taxonomy slugs for same hierarchical children
- Shortcode inserts paragraphs before and after executing shortcode
- Get_template_part inside a folder
- Passing values from a widget to a function within a plugin
- Contact Form 7 – Delay auto responds
- add code in functions.php will slow down the Execution speed?
- Custom Post excerpt not working correctly
- Replace a menu with widget or a custom template file programmatically
- Wait a result before enqueue
- Which functions/classes are available during SHORTINIT?
- Function added using `add_action()` not being called
- How to pass variables from a function in functions.php to an other one
- How to edit the Tags within the image file URLs?
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- Add code to Functions.php
- Disable wp_is_mobile()
- How can we know we are not in edit page
- Adding jQuery datepicker to Custom Post Type Metabox [closed]
- Allowed memory size of 33554432 bytes exhausted (tried to allocate 9967617 bytes) in …\wp-includes\functions.php
- What happens to the text in functions.php file outside of the php enclosure?
- wordpress acts like functions.php doesn’t exist [closed]
- retrieves menu and converts it to a readable array
- How to properly set custom logo size?
- Image Crop Not Working
- WordPress can’t get jquery/unslider to work
- how get number of twitter followers in wordpress
- template_redirect action only firing if logged in
- Unable to use get_page_by_title() more than once per page?
- How to Display WooCommerce Product Price in WooCommerce Archive
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Featured Image and Tags problem
- Advanced method to control cache of enqueued style/script
- Issue passing action class to nested function. Admin Columns
- large image size of 1440×1440 not pulling 2x of 2880×2880 image
- How to make the RTL.css the dominant css code?
- Its my first time trying to create a website , I got an error Please help
- Load scripts into an AJAX div
- restrict uploaded image size and fixed image display size
- Code executes outside of Loop while same code gives ‘Uninitialized string offset’ notice inside a while loop
- Function not receiving string from shortcode
- I’m getting invalid taxonomy in init action
- Is there any requirements to do socket programming with WordPress?
- Restricted images only for logged user. (hidden url)
- Only seems to be displaying one child when there are supposed to be multiple
- Rest API User Levels
- adding google analytics via echo or between tags
- Slider Thumbnail Size Issue [closed]
- same get_posts function works diffrently in tag.php and functions.php
- Call custom field using php
- WordPress permanently logging users out
- Meta Box value not been pulled in
- Syling Custom Fields echo’s from from functions.php
- How to Update User Meta Field other than from profile?
- Retrieve array of attachment IDs attached to a given Post ID
- add_theme_support not outputting thumbnails
- More link – not text
- update_user_option not working as expected
- Shortcodes not outputting in correct divs
- Help finishing script to export WP user data when form submitted
- PHP Notice: Function is_page was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false
- WordPress Custom wp mail template return full template
- Comment turned Invisible