Skip to content

Instantly share code, notes, and snippets.

@craigsimps
Created March 15, 2018 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigsimps/5043846c089a7e6a6cce646237cea605 to your computer and use it in GitHub Desktop.
Save craigsimps/5043846c089a7e6a6cce646237cea605 to your computer and use it in GitHub Desktop.
<?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