Can my “add_action” function know the name of the hook calling it?
function pj_time () { echo current_filter(); } Easier than I thought đŸ˜‰ http://codex.wordpress.org/Function_Reference/current_filter
function pj_time () { echo current_filter(); } Easier than I thought đŸ˜‰ http://codex.wordpress.org/Function_Reference/current_filter
add_filter(‘wpseo_robots’, ‘yoast_no_home_noindex’, 999); function yoast_no_home_noindex($string= “”) { if (is_home() || is_front_page()) { $string= “index,follow”; } return $string; } this should be fine i think.. somewhere in your theme functions.php and should do the trick.
Have a look at the codex page for add_filter. The 10 is the $priority parameter (10 is default) which defines when your function will run in regards to the other functions which are attached to the nav_menu_css_class filter. 2 is the $accepted_args parameter which tells wordpress how many parameters the function you want to add … Read more
init is much earlier than page template loading and not appropriate place for enqueues (despite many tutorials and docs using it for that). Hook your function to wp_enqueue_scripts and make sure you are doing that hooking before wp_head() call in template.
If you pass an array to do_action_ref_array(), each element’s value of that array will be passed as a separate parameter to the callback. The keys are lost. If you pass an array to do_action(), the complete array will be passed as one single parameter to the callback. The keys stay intact. Let’s look at the … Read more
There are a couple of issues with your approach By using the admin_init hook you won’t have any reference to the post object. This means you won’t be able to get the post ID or use anything like get_the_ID because the post won’t actually be loaded. You can see that in the order here https://codex.wordpress.org/Plugin_API/Action_Reference … Read more
Is there any hook that fires once the image is uploaded and the image sizes generated? wp_handle_upload fires after the image is uploaded. After the follow-up question, I discovered that images would not be sized at this point. add_filter( ‘wp_handle_upload’ ‘wpse_256351_upload’, 10, 2 ); function wpse_256351_upload( $upload, $context ) { //* Do something interesting return … Read more
The errors I’ve spotted in your code: One was pointed by @helgatheviking in a comment: the Ajax callback has to be a public method, not private. Not sure how are you initializing this class, but wp_enqueue_script&_style (in singular) has to be encapsulated inside a wp_enqueue_scripts hook (WP_DEBUG dumps a notice). You can drop the & … Read more
Well, ended up fixing this after hours of banging my head against ones keyboard. Fixed by making the first parameter of my hooked function a value instead of a reference – curious when nearly all hooks in wordpress pass the error object by reference! function validatePasswordReset( &$errors, $userData ) { return validateComplexPassword( $errors ); } … Read more
The ‘save_post’ action was added to core in 2.0, and has always been an action. Looking through the current autosave procedures, it doesn’t appear to call the ‘save_post’ action directly at any time. So the short answer is, no. There is no reason, and has never been any reason, to return any value on this … Read more