Introduction to the PHP functions used in WordPress to get the home page and site links

Source: Internet
Author: User
This article describes the PHP functions used in WordPress to obtain the home page and site links. For more information, see home_url () and site_url (). Home_url () (get the homepage link)
The ome_url () function is used to obtain the WordPress homepage link.

Usage

home_url( $path, $scheme );

Parameters

$ Path

(String) (optional) The content appended to the homepage link is a relative link.

Default value: None

$ Scheme

(String) (optional) connection protocol. only "http", "https", and "relative" are supported ".

Default value: null

Return value

(String) returns the home page URL with the $ path parameter.

Example

Echo home_url (); // output: http://www.example.comecho home_url ('/'); // output: http://www.example.com/echo home_url ('/', 'https'); // output: https://www.example.com/echo home_url ('example ', 'relative'); // output:/example

Others
This function is located in: wp-des/link-template.php


Site_url () (get site link)
The site_url () function is used to obtain the WordPress site link.

Usage

site_url( $path, $scheme );

Parameters

$ Path

(String) (optional) content appended after the link.

Default value: None

$ Scheme

(String) (optional) connection protocol. only "http", "https", "login", "admin", and "relative" are allowed ".

Default value: null

Return value

(String) returns the site link with the $ path parameter.

Example

Echo site_url (); // output: http://www.example.com or http://www.example.com/wordpressecho site_url ('/secrets/', 'https'); // output: https://www.example.com/secrets/ or https://www.example.com/wordpress/secrets/

Others

This function is located in: wp-des/link-template.php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.