Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
add_action( 'template_redirect', __NAMESPACE__ . '\\hide_single_testimonials' );
/**
* We don't want to show single testimonials, only the archive.
*
* If someone tries to visit a single testimonial this action will ping them back to the testimonials archive.
*
* @since 1.0.0
*/
function hide_single_testimonials() {
if ( is_singular( [ 'me_testimonials' ] ) ) {
wp_redirect( get_post_type_archive_link( 'me_testimonials' ), 301 );
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.