Link Tags

1)the_permalink()

Description
Displays the URL for the permalink to the post currently being processed in The Loop. This tag must be within The Loop, and is generally used to display the permalink for each post, when the posts are being displayed. Since this template tag is limited to displaying the permalink for the post that is being processed, you cannot use it to display the permalink to an arbitrary post on your weblog. Refer to get_permalink() if you want to get the permalink for a post, given its unique post id.

Usage
 <?php the_permalink(); ?> 

Parameters
Before 4.4.0, this tag has no parameters. Since 4.4.0: Added the `$post` parameter.

Examples
Display Post URL as Text
Displays the URL to the post, without creating a link:
This address for this post is: <?php the_permalink(); ?>
As Link With Text
You can use whatever text you like as the link text, in this case, "permalink".
<a href="<?php the_permalink(); ?>">permalink</a>
Used as Link With Title Tag
Creates a link for the permalink, with the post's title as the link text. This is a common way to put the post's title.
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>

2)get_permalink()

Description
Displays the URL for the permalink to the post currently being processed in The Loop. This tag must be within The Loop, and is generally used to display the permalink for each post, when the posts are being displayed. Since this template tag is limited to displaying the permalink for the post that is being processed, you cannot use it to display the permalink to an arbitrary post on your weblog. Refer to get_permalink() if you want to get the permalink for a post, given its unique post id.

Usage
 <?php the_permalink(); ?> 

Parameters
Before 4.4.0, this tag has no parameters. Since 4.4.0: Added the `$post` parameter.

Examples
Display Post URL as Text
Displays the URL to the post, without creating a link:
This address for this post is: <?php the_permalink(); ?>
As Link With Text
You can use whatever text you like as the link text, in this case, "permalink".
<a href="<?php the_permalink(); ?>">permalink</a>
Used as Link With Title Tag
Creates a link for the permalink, with the post's title as the link text. This is a common way to put the post's title.
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>

3)home_url()

Description
The home_url template tag retrieves the home URL for the current site, optionally with the $path argument appended. The function determines the appropriate protocol, "https" if is_ssl() and "http" otherwise. If the $scheme argument is "http" or "https" the is_ssl() check is overridden.
In case of WordPress Network Setup, use network_home_url() instead.

Usage
<?php home_url( $path, $scheme ); ?>
Default Usage
<?php echo esc_url( home_url( '/' ) ); ?>

Parameters
$path
(string) (optional) Path relative to the home URL.
Default: None
$scheme
(string) (optional) Scheme to use for the home URL. Currently, only "http", "https" and "relative" are supported.
Default: null

Return
(string)
Home URL with the optional $path argument appended.

Example
$url = home_url();
echo esc_url( $url );
Output: http://www.example.com

4)get_home_url()

Description
The home_url template tag retrieves the home URL for the current site, optionally with the $path argument appended. The function determines the appropriate protocol, "https" if is_ssl() and "http" otherwise. If the $scheme argument is "http" or "https" the is_ssl() check is overridden.
In case of WordPress Network Setup, use network_home_url() instead.

Usage
<?php home_url( $path, $scheme ); ?>
Default Usage
<?php echo esc_url( home_url( '/' ) ); ?>

Parameters
$path
(string) (optional) Path relative to the home URL.
Default: None
$scheme
(string) (optional) Scheme to use for the home URL. Currently, only "http", "https" and "relative" are supported.
Default: null

Return
(string)
Home URL with the optional $path argument appended.

Example
$url = home_url();
echo esc_url( $url );
Output: http://www.example.com


5)site_url()

Description
The site_url template tag retrieves the site url for the current site (where the WordPress core files reside) with the appropriate protocol, 'https' if is_ssl() and 'http' otherwise. If scheme is 'http' or 'https', is_ssl() is overridden. Use this to get the "WordPress address" as defined in general settings. Use home_url() to get the "site address" as defined in general settings.
In case of WordPress Network setup, use network_site_url() instead.
Usage
<?php site_url( $path, $scheme ); ?>
Default Usage
<?php echo site_url(); ?>
Parameters
$path
(string) (optional) Path to be appended to the site url.
Default: None
$scheme
(string) (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'.
Default: null
Return
(string)
Site url link with optional path appended.
Examples
$url = site_url();
echo $url;

6)get_site_url()

Description
The site_url template tag retrieves the site url for the current site (where the WordPress core files reside) with the appropriate protocol, 'https' if is_ssl() and 'http' otherwise. If scheme is 'http' or 'https', is_ssl() is overridden. Use this to get the "WordPress address" as defined in general settings. Use home_url() to get the "site address" as defined in general settings.
In case of WordPress Network setup, use network_site_url() instead.

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

Default Usage
<?php echo site_url(); ?>

Parameters
$path
(string) (optional) Path to be appended to the site url.
Default: None
$scheme
(string) (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'.
Default: null
Return
(string)
Site url link with optional path appended.

Examples
$url = site_url();
echo $url;





No comments:

Post a Comment

=>SEO

1.  Syllabus 2.  Unit Wise Question/Material 3. Paper 4. Previous Paper