How to access page variable inside action hook

There is method on product class that is called is_on_sale() which actually determines if the product is on sale or not. You can access it from global $product variable. And must echo the do_shortcode. So the whole code will be like- add_action(‘woocommerce_single_product_summary’,’add_product_signup’, 10, 2); function add_product_signup() { global $product; if( $product->is_on_sale() ) { echo do_shortcode(‘[contact-form-7 … Read more

WooCommerce coupon hook argument NULL when using filter woocommerce_get_shop_coupon_data

You need to tell add_filter how many arguments it accepts (2) example: add_filter(‘woocommerce_get_shop_coupon_data’, array( $this, ‘filter_woocommerce_get_shop_coupon_data’ ), 10, 2 ); Be sure to enable WP_Debug – http://wpexplorer-themes.com/total/docs/enabling-wp-debug/ – on your server, because you should have gotten an error when trying to do this without the added argument. Also I highly recommend using static classes when … Read more

Stripping URLs & Email from post submissions

You can use the_content (Click here for more info) hook to change the content while rendering the post/page. This will be triggered when Post is being read from Database. So post content will not be changed in database but only filtered while rendering. add_filter( ‘the_content’, ‘remove_email_and_url_from_post’ ); function remove_email_and_url_from_post( $content ) { // Check if … Read more

Add/remove CRON action depending on variable

I am not sure why the remove_action isn’t working because by the looks of your code, it should. Alternatively, you can add the conditional logic to your generate_sitemap() function generate_sitemap() { global $create_sitemap; if ( $create_sitemap ) return false; $sitemap = ‘<?xml version=”1.0″ encoding=”UTF-8″?>’; $sitemap .= ‘<urlset xmlns=”http://www.sitemaps.org/schemas/sitemap/0.9″>’; // Get a query of all jobs … Read more

Rewrite rule and display of post

I don’t understand why but the regex seemed to be the last issue. It was catching it but even with the post name hardcoded in it didn’t work correctly. This is the final working version. add_filter( ‘post_link’, ‘custom_permalink’, 10, 3 ); add_filter(‘rewrite_rules_array’,’wp_insertMyRewriteRules’); add_filter(‘init’,’flushRules’); function custom_permalink( $permalink, $post, $leavename ) { $category = get_the_category($post->ID); if ( … Read more