2 years ago
#68157
Kane
add_action run for the specific page
Hi I have faced a problem on my code. I wanted to run add_action for the certain page. add_action is working individually when I Put this on the functions.php but when I tried to run this in wp_head action then its not working.
add_action( 'wp_head', 'remove_my_action', 0);
function remove_my_action($post) {
global $post;
$post_id = $post->ID;
if (512 == $post_id) {
echo "Page Found";
remove_action( 'woocommerce_add_to_cart', 'add_product_to_cart');
}else{
add_action('woocommerce_add_to_cart', 'add_product_to_cart');
}
}
php
wordpress
hook
add-action
0 Answers
Your Answer