Custom field in PHP file

Assuming your $hasp_expire_date = get_post_meta( $post_id, ‘hasp_expire_date’, true ); is giving you the correct value you need, you are storing your that in the $hasp_expire_date variable. So edit that second line to: $num_comments = get_comments_number( $block_data[‘id’] ); // Pull in the value you need $hasp_expire_date = get_post_meta( $post_id, ‘hasp_expire_date’, true ); // You are going … Read more

WP_get_image_editor resizing images in a foreach loop

wp_get_image_editor can return a WP_Error object, which appears to be what’s happening in the code. The code never checks for this and tries to resize an image, thinking it’s calling resize on an image editing object. You need to make 2 adjustments: check if $editor is a WP_Error object add code to print out the … Read more

WooCommerce – template_redirect if is_checkout AND order has been paid?

I figured it out. woocommerce_payment_succesful_result guided me in the right direction, although it wasn’t the final answer. function is_wc_endpoint_url() is really useful here, it checks where woocommerce is about to redirect next. // redirect empty checkouts and completed orders. add_action( ‘template_redirect’, ‘myfunction’ ); function myfunction() { if( is_wc_endpoint_url( ‘order-received’ ) && isset( $_GET[‘key’] ) ) … Read more