Using SSL with WordPress

If you have an SSL setup for your domain, it is pretty simple to set wordpress to use https. If you want the entire site to use https, you can set it under settings for your Site URL. Sometimes though you want only a specific page using https. To do that you need to know the page ID and make a small change to the code.

function force_ssl($force_ssl, $id = 0) {

  // List posts/pages that should have ssl
  $ssl_posts = array(1, 4);

  if(in_array($id, $ssl_posts)) {
    $force_ssl = true;
  }
    return $force_ssl;
}
add_filter('force_ssl' , 'force_ssl', 1, 3);

Its that simple, that change will set those posts/pages to use https rather than http and your post is now secured with SSL.

Leave a Reply

Your email address will not be published. Required fields are marked *