Redirect 404 to Homepage
add_action( ‘template_redirect’, function() { if (is_404()) { wp_safe_redirect(home_url()); exit(); } } );Continue reading
Join 2,000,000+ Professionals who use WPCode to Future-Proof Their Websites!
add_action( ‘template_redirect’, function() { if (is_404()) { wp_safe_redirect(home_url()); exit(); } } );Continue reading
add_action( ‘template_redirect’, function() { if (is_404()) { wp_safe_redirect(home_url()); exit(); } } );Continue reading
add_action( ‘template_redirect’, function () { global $post; if ( ! is_attachment() || ! isset( $post->post_parent ) || ! is_numeric( $post->post_parent ) ) { return; } // Does the attachment have a parent post? // If the post is trashed, fallback…Continue reading
add_action( ‘template_redirect’, function () { global $post; if ( ! is_attachment() || ! isset( $post->post_parent ) || ! is_numeric( $post->post_parent ) ) { return; } // Does the attachment have a parent post? // If the post is trashed, fallback…Continue reading
add_action( ‘template_redirect’, function () { global $post; if ( ! is_attachment() || ! isset( $post->post_parent ) || ! is_numeric( $post->post_parent ) ) { return; } // Does the attachment have a parent post? // If the post is trashed, fallback…Continue reading
add_action( ‘template_redirect’, function () { global $post; if ( ! is_attachment() || ! isset( $post->post_parent ) || ! is_numeric( $post->post_parent ) ) { return; } // Does the attachment have a parent post? // If the post is trashed, fallback…Continue reading
/* Get Statuscode 404 for existing & non-existing author archives. */ add_action( ‘template_redirect’, function() { if ( isset( $_GET[‘author’] ) || is_author() ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } }, 1 ); /* Remove the Author Links…Continue reading
function cmplz_my_filter_site_needs_cookiewarning( $cookiewarning_required) { //don’t show cookie banner for logged in users if ( is_user_logged_in() ) { $cookiewarning_required = false; if (!defined(‘CMPLZ_DO_NOT_BLOCK’) ) define(‘CMPLZ_DO_NOT_BLOCK’, true); } return $cookiewarning_required; } add_filter( ‘cmplz_site_needs_cookiewarning’, ‘cmplz_my_filter_site_needs_cookiewarning’ );Continue reading
add_action( ‘template_redirect’, function () { global $post; if ( ! is_attachment() || ! isset( $post->post_parent ) || ! is_numeric( $post->post_parent ) ) { return; } // Does the attachment have a parent post? // If the post is trashed, fallback…Continue reading
add_action( ‘template_redirect’, function () { global $post; if ( ! is_attachment() || ! isset( $post->post_parent ) || ! is_numeric( $post->post_parent ) ) { return; } // Does the attachment have a parent post? // If the post is trashed, fallback…Continue reading