0

I have a custom post type that uses the main single page only on specific terms, but others really don't need the single. I want to avoid a user accessing the permalink for all of the terms but one. I imagine there must be a way to "extend" the main custom post type rule to be used only on specific terms but not sure. I guess there's no "official" wordpress way of doing it but maybe using custom functions? Any clues?

1

1 Answer 1

0

ok - so this isn't what I wanted but it does the trick. Adding a function to redirect when the user hits any term but one:

function my_page_template_redirect() {
    if( is_singular( 'custom-post-type' ) && !(has_term('term', 'custom-taxonomy')) ) {
        wp_redirect( home_url(), 301 );
        exit();
    }
}
add_action( 'template_redirect', 'my_page_template_redirect' );

Answer based on this one: Disable Single Post View for Specific Taxonomy on Custom Post Type

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.