Home > Backend Development > PHP Tutorial > Introduction to PHP functions in WordPress for getting homepage and site links

Introduction to PHP functions in WordPress for getting homepage and site links

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 09:10:12
Original
973 people have browsed it

home_url() (get the homepage link) The
ome_url() function is used to get the WordPress homepage link.

Usage

home_url( $path, $scheme );

Copy after login

Parameters

$path

(string) (optional) The content appended after the homepage link is a relative link.

Default value: None

$scheme

(String) (optional) Link protocol, only supports "http", "https" and "relative".

Default value: null

Return value

(String) Returns the home page URL plus the $path parameter.

Example

echo home_url();//输出:http://www.example.com
echo home_url( '/' );//输出:http://www.example.com/
echo home_url( '/', 'https' );//输出:https://www.example.com/
echo home_url( 'example', 'relative' );//输出:/example

Copy after login

Others
This function is located at: wp-includes/link-template.php


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

Usage

site_url( $path, $scheme );
Copy after login

Parameters

$path

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

Default: None

$scheme

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

Default value: null

Return value

(String) Returns the site link plus the $path parameter.

Example

echo site_url();//输出:http://www.example.com 或者 http://www.example.com/wordpress
echo site_url( '/secrets/', 'https' );//输出:https://www.example.com/secrets/ 或者 https://www.example.com/wordpress/secrets/
Copy after login

Others

This function is located at: wp-includes/link-template.php

The above is an introduction to the PHP functions used to obtain homepage and site links in WordPress, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Is the example here wrong?
From 1970-01-01 08:00:00
0
0
0
PHP two-way queue example explanation
From 1970-01-01 08:00:00
0
0
0
Example of many-to-many relationship
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template