Created
March 15, 2018 16:36
-
-
Save craigsimps/5043846c089a7e6a6cce646237cea605 to your computer and use it in GitHub Desktop.
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
<?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