Add a class with body_class to a specific url with parameter

You’re overcomplicating it a bit. ?um_action=edit is a query string, and its values are available in the $_GET superglobal. To check if it exists, and has a specific value, you just need to do this: function leweb_add_body_class_um_edit_profile( $classes ) { if ( isset( $_GET[‘um_action’] ) && ‘edit’ === $_GET[‘um_action’] ) { $classes[] = ‘leweb-um-profile-edit’; } … Read more

Where is this function’s callback getting its arguments from?

If you have a look at function do_meta_boxes() in wp-admin/includes/template.php then you’ll see this line close to the end of the function: call_user_func($box[‘callback’], $object, $box); That calls the callback function and provides the two arguments. The $box argument holds all the information about the metabox, like ID, title, callback function. In wp-admin/edit-form-advanced.php, which displays your … Read more

How to parse a custom url (within WP site) and obtain params passed to that URL

First, you register your query vars param1 and param2: function wpse_101951_query_vars( $qv ) { $qv[] = ‘param1’; $qv[] = ‘param2’; return $qv; } add_filter( ‘query_vars’, ‘wpse_101951_query_vars’ ); To use this information, you can pretty much hook into any action or filter after parse_query. That’s the first action available after the query vars are set, so … Read more

missing argument 2 when passing arguments to add_action

This problem can be met when hooking in whatever hook that has already been triggered by a precedent do_action (ie. when this_hook has already been mentionned in a do_action within the core files of wordpress or within whatever plugin files) In that particular case, demanding arguments when registering a new function within an add_action(‘this_hook’,’function’, $priority, … Read more