Hot answers tagged


For this example lets say we have the following do_action('bt_custom_action', get_the_ID(), get_the_title(), get_the_content()); The arguments that will be passed to add_action would be in this order the post id the post title the post content By default if we hook into our do_action without any arguments, like this add_action('bt_custom_action', '...


I found the magic code you need. Use current_filter(). This function will return name of the current filter or action. add_action('my_test_hook_1','my_test_callback_function'); add_action('my_test_hook_2','my_test_callback_function'); add_action('my_test_hook_3','my_test_callback_function'); add_action('my_test_hook_4','my_test_callback_function'); function ...


Everything Butterend_Toast says is correct, but I want to touch on why it works that way. Under the hood, do_action() and apply_filters() are just calling the core PHP function call_user_func_array(). When you run add_action() you are storing a reference to a callable, with a number representing how many arguments that function accepts. add_action( '...


The action you are looking for is wp_body_open(). I do not know if you are writing your own theme or not but if you are using a pre-built theme, the author of your theme may not have included this support. If properly supported in your theme, any function hooked to this action will be called immediately after the page opening <body> element. WordPress ...


You can't, and it doesn't make sense to do so. Different pages/URLs enqueue different things, e.g. a WP Admin page won't enqueue the same styles and scripts, widgets might enqueue things conditionally, etc. But in WP CLI those hooks don't run, and there is no page or frontend. So the question doesn't make sense at a fundamental level. It isn't enough to know ...


You want a "Must Use Plugin". Any PHP files placed in wp-content/mu-plugins will be run automatically, and can only be 'deactivated' by removing the file.


This is a bug in WP core 5.6.1: which will hopefully be fixed by this:


Where am I going wrong? Actually, your code is just fine. Except that I would simply use wp_generate_password() to generate the random string. :) WordPress will still think that the scaled version is called painting-scaled.jpg , etc. Resulting in broken images. Yes, that's correct. Images are stored as posts of the attachment type in the WordPress posts ...


If you have code that must run before plugins are loaded, place it in a Must Use Plugin. This is just a PHP file placed in wp-content/mu-plugins/. Be aware that Must Use Plugins are activated just by existing.

Only top voted, non community-wiki answers of a minimum length are eligible