Failed to invoke other hook from the init hook

Related to this question (Use wp init hook to call other hooks?) but not the same. Sometimes, I found that the hook will failed to run when I place inside the init hook, e.g. Not Work: add_action(‘init’,’my_init’); function my_init() { add_filter(‘locale’, … } Work: add_action(‘init’,’my_init’); add_filter(‘locale’, … Of course some hooks/filters will just work okay … Read more

add_filter to ‘woocommerce_before_main_content’ [closed]

Closed. This question is off-topic. It is not currently accepting answers. Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third party plugins and themes are off topic, they are better asked about at their developers’ support routes. Closed 6 … Read more

Setting Cookie with init hook causes ‘header already sent’

Based on research here and elsewhere, I have the following code that sets a cookie on a site: add_action( ‘init’, ‘my_set_cookie’,1 ); function my_set_cookie() { if (! $_COOKIE[‘mycookie’]) { $guid = ‘xxxx’; // normally a real guid value so it will be unique setcookie(‘mycookie’, $guid, time()+(3600*24*30),””); } return; } But even though the init hook … Read more

How to unhook a function in Woocommerce Template?

I have a basic question that has always stumped me. I’m trying to move the Star Rating into the comment meta, which will help me style it. Here’s the template file review.php section: <div class=”comment-text”> <?php /** * The woocommerce_review_before_comment_meta hook. * * @hooked woocommerce_review_display_rating – 10 //Want to unhook this. */ do_action(‘woocommerce_review_before_comment_meta’, $comment); /** … Read more