Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. /**
  2. * Redirect CTP single to CPT archive.
  3. */
  4. function dom_single_redirect_post() {
  5. $queried_post_type = get_query_var('post_type');
  6. if (
  7. is_single() && 'team' == $queried_post_type ||
  8. is_single() && 'kranten' == $queried_post_type ||
  9. is_single() && 'klanten' == $queried_post_type ||
  10. is_single() && 'geschiedenis' == $queried_post_type
  11. ) {
  12. wp_redirect( get_post_type_archive_link($queried_post_type), 301 );
  13. exit;
  14. }
  15. }
  16. add_action( 'template_redirect', 'dom_single_redirect_post' );
  17.  
  18.  
  19. /**
  20. * Add noindex, nofollow to CPT single.
  21. */
  22. add_filter( 'the_seo_framework_robots_meta_array', function( $meta ) {
  23. if ( is_singular( array( 'team', 'kranten', 'klanten', 'geschiedenis' ) ) ) {
  24. if ( the_seo_framework() ) {
  25. $meta['noindex'] = 'noindex';
  26. $meta['nofollow'] = 'nofollow';
  27. }
  28. }
  29. return $meta;
  30. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement