Articles of hooks

dynamic_sidebar in add_action not showing custom menu widget items text

The custom menu widget and pages widget does not show the text in the li items, but the structure seems to be ok. Anyone have a clue why this might be? Other widgets seem to output the text add_action(‘myAction’, function(){ dynamic_sidebar(‘sidebar-1’); }); here is the menu output…no text in the anchor tags… <div class=”menu-gameplan-container”><ul id=”menu-gameplan” […]

Change Checkout “Place Order” text if cart has a specific product

In WooCommerce, I am looking for a function to change the “Place Order” text if cart has a specific product(ID) on checkout page. This is useful for woo shops selling product and at the same time offering different services for example memberships. This will make the place order text more descriptive of the product as […]

How to assign roles to a variable to be used in a plugin function?

Why would this:$role_name = $user->roles[0]; work as a variable in a function when the hook in add_action is wp_login, and give an error of Notice: Trying to get property of non-object when a hook created in header.php is used instead? How could I go about applying the user roles to a variable string to use […]

How to stop WordPress from updating the post meta

I have tried using many hooks to achieve this. I don’t want one of my post meta to be updated when we update post. I tried doing something like : add_filter( ‘update_post_metadata’, ‘wpse_163859’, 10, 5 ); function wpse_163859( $check, $object_id, $meta_key, $meta_value, $prev_value ) { return false; } I tried looking at meta.php in wp-includes, […]

How WordPress understands what do with the (all) key in the $wp_filter array?

This question already has an answer here: What is “all” in isset($wp_filter['all']) 2 answers

Function added to hook “new_to_publish” not executing – custom plugin

I was creating a custom plugin which was to send certain emails based on the content/category of a post, but whilst trying to do that, I ran into some problems just getting a basic email sent out. Am I hooking on to the wrong function here? When I publish a post, nothing happens. <?php /** […]

How to detect when a user changes their name?

I am trying to detect when a user changes their name. I have tried using the profile_update hook: add_action( ‘profile_update’, ‘my_profile_update’, 10, 2 ); function my_profile_update( $user_id, $old_user_data ) { https://codex.wordpress.org/Plugin_API/Action_Reference/profile_update I can access the $_POST data to get the new name fields, but $old_user_data does not contain the name fields, and because this fires […]

Hooks for the new PressThis Bookmarklet

When I find content worth spreading I should know more than text contents and image URLs. I need some more copyright informations, the licence, author name, image title, the date published etc. In my site I use hundreds of Categories and Tags. So in the WP backend Editor I turned the sidebar into new easy […]

Alter theme pages on language switch

I stumbled upon an issue that I’m not sure how to go forward with. My theme creates two pages on activation. The fact that there are two doesn’t matter, it could be 10 pages but just for the background: One page can be selected as a FrontPage. Another one is used to display all categories. […]

WordPress PlugIn for Post Views

This is my first time developing a WordPress plugin for a blog, to keep track and display the post views. I am not the owner of the blog, so I have no way to test my plugin. This is what I have till now. add_action(“wp_head”, “tracker_add_view”); function tracker_add_view() { // Function to retrieve current post […]