How to customize file path for 404 redirection in php?

This should work for you, using plugins_url(): … // Assumes that your templates are in a subdirectory called ‘templates’ in your plugin. // Adjust accordingly. $templates_dir = plugins_url( ‘templates’, __FILE__ ); $page_404 = $templates_dir . ‘/404-‘ . $post_type . ‘.php’ ); … Update: template_include If you want to have WordPress loaded up, you might be … 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