Add option to redirect team pages to site url

This commit is contained in:
Brian Miyaji
2017-01-05 16:52:28 +11:00
parent 2ca603e7e6
commit 1b805f7bb8
2 changed files with 17 additions and 9 deletions

View File

@@ -211,12 +211,20 @@ add_filter( 'gettext', 'sportspress_gettext', 20, 3 );
function sportspress_team_permalink( $permalink, $post ) {
if ( ! is_admin() && 'sp_team' == get_post_type( $post ) ):
if ( empty( $post->post_content ) ):
$url = get_post_meta( $post->ID, 'sp_url', true );
if ( ! empty( $url ) ):
return $url;
endif;
endif;
$url = get_post_meta( $post->ID, 'sp_url', true );
if ( ! empty( $url ) ):
$redirect = get_post_meta( $post->ID, 'sp_redirect', true );
if ( $redirect === '' ):
$redirect = ( empty( $post->post_content ) ) ? 1 : 0;
endif;
if ( $redirect ):
return $url;
endif;
endif;
endif;
return $permalink;
}