what is the action hook code to supporting product category condition in single product page of woocommerce?

Firstly, this conditional returns true on category archives for Woo Commerce and NOT single product page. Try using the actual slug in lowercase or the i.d. Example: if ( is_product_category( ‘t-shirt’ ) ) { Your code looks like its wrong because it includes too many brackets. Woo suggest using the slug in their Docs. This … Read more

About Hooks and Filters

Seeing that you’ve referenced 3 Genesis Developers, i’d like to answer this question using 2 Genesis code snippets as well as 2 WordPress examples of action hooks and filters. Hooks Different template files in Genesis include hooks which simply enable you to execute PHP code in that position of the template. Here’s a visual guide … Read more

Hooks are not executing

The do_action is in the wrong place. It is calling it’s self. You have this: public function hook_name() { do_action(‘hook_name’); } Do this: do_action(‘hook_name’); public function hook_name() { do_action(‘other_hook_name’); }

Count singular post views automatically

You could hook into template_redirect and execute a helper function: add_action( ‘template_redirect’, ‘wpse_75558_count’ ); function wpse_75558_count() { if ( is_singular() ) setPostViews( get_the_ID() ); } To display the post views, you have to use a later hook. I would recommend the_content: add_filter( ‘the_content’, ‘wpse_75558_show_count’ ); function wpse_75558_show_count( $content ) { $count = getPostViews( get_the_ID() ); … Read more

Fatal error: Call to undefined function add_action() – an untouched problem

get_stylesheet_directory_uri() returns an URL. The requested file is called like any other publicly available resource: without the context of the include statement. This is like opening the PHP file in a browser directly. There is no WordPress context, and the functions add_action() or add_filter() are not defined. Use get_template_directory() in parent themes and get_stylesheet_directory() in … Read more

How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’

Updated: First, you will need to return a bool value on your notifications method so we can reliably set a marker for the message method. Then, you will need to set a $_POST array element to pass on to the redirection filter. public function save_post($post_id){ //Add a $_POST key if you syndicated successfully if($this->send_group_notifications()) //return … Read more

How to remove an action that is added inside a class

I don’t understand any of it but it seems to work just fine. Thank you @Buttered_Toast for mentioning the useful thread. add_action(“init”, function() { global $wp_filter; foreach($wp_filter[“wp”][10] as $id => $filter) { if(is_array($filter[“function”]) && count($filter[“function”]) == 2 && get_class($filter[“function”][0]) == “Post_Views_Counter_Columns” && $filter[“function”][1] == “admin_bar_maybe_add_style”) { remove_action(“wp”, $id); } } }, 99);