What does $scheme in site_url function do?

<?php site_url( $path, $scheme ); ?>

Parameters

$path: (optional) Path to be appended to the site url.

$scheme: (optional) Context for the protocol for the url returned. Setting $scheme will override the default context. Allowed values are ‘http’, ‘https’, ‘login’, ‘login_post’, ‘admin’, or ‘relative’.

It simply overrides the default parameters in URL.

For example if you have a website URL like http://www.example.com (without https) and you want to add https URL on a specific link instead of http, then you use $scheme parameter.

Leave a Comment