Last active
August 19, 2024 02:40
-
-
Save ingozoell/d22b98c8c0579b5da599 to your computer and use it in GitHub Desktop.
WordPress: Remove unused archive Pages (tax, cat ) and redirect 404
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
function taxonomies_redirect() { | |
if( is_tax('filter') ) { | |
wp_redirect( home_url('/fotouebersicht/'), 301 ); | |
exit; | |
} | |
} | |
add_action( 'template_redirect', 'taxonomies_redirect' ); | |
*/ | |
// Remove Taxonomies Single Page (404 Error) | |
function remove_taxonomies_urls() { | |
if( is_tax('filter') ) { | |
global $wp_query; | |
$wp_query->set_404(); | |
} | |
} | |
add_action( 'template_redirect', 'remove_taxonomies_urls' ); | |
/* | |
function cpt_portfolio_redirect() { | |
if ( 'portfolio' == get_post_type() ) { | |
wp_redirect( home_url('?slide=models'), 301 ); | |
exit; | |
} | |
} | |
add_action( 'template_redirect', 'cpt_portfolio_redirect' ); | |
*/ | |
// Remove CPT Single Page (404 Error) | |
function remove_cpt_portfolio_urls() { | |
if ( 'portfolio' == get_post_type() ) { | |
global $wp_query; | |
$wp_query->set_404(); | |
} | |
} | |
add_action( 'template_redirect', 'remove_cpt_portfolio_urls' ); | |
// https://blog.kulturbanause.de/2016/02/wordpress-single-seiten-von-custom-post-types-umleiten/ | |
function kb_template_redirect() { | |
if(is_singular('NAME DES POST TYPES')) { | |
wp_redirect( home_url('/SLUG DER ÜBERSICHTSSEITE/') ); | |
exit(); | |
} | |
} | |
add_action('template_redirect', 'kb_template_redirect'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment