Skip to content

Instantly share code, notes, and snippets.

@WebEndevSnippets
Created July 25, 2013 15:45
Show Gist options
  • Save WebEndevSnippets/6081062 to your computer and use it in GitHub Desktop.
Save WebEndevSnippets/6081062 to your computer and use it in GitHub Desktop.
WordPress: Redirect Page to HTTPS Secure (SSL)
add_action( 'template_redirect', 'webendev_secure_template_redirect', 1 );
/**
* Redirect Page to https scheme
*/
function webendev_secure_template_redirect() {
global $post;
if ( ( genesis_get_custom_field( 'wps_force_ssl' ) || is_page( 2048 ) ) && 'on' != $_SERVER['REDIRECT_HTTPS'] && 'on' != $_SERVER['HTTPS'] ) {
$post_data = get_post( $post->ID, ARRAY_A );
wp_redirect( site_url( $post_data['post_name'], 'https' ) );
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment