the_privacy_policy_link()WP 4.9.6

Outputs a link (html) to the privacy policy page.

The privacy page can be specified in the admin panel Settings > Privacy. The anchor of the link is the title of the page.

Use get_the_privacy_policy_link() when you need to get the result, not output it to the screen.

1 time — 0.003337 sec (very slow) | 50000 times — 8.74 sec (fast) | PHP 7.0.32, WP 5.1.1

No Hooks.

Returns

null. The function outputs the html code of the link to the screen if the privacy policy page is specified in the admin panel and is published. Otherwise, it outputs nothing.

Usage

the_privacy_policy_link( $before, $after );
$before(string)
Text/HTML code to place before the link.
Default: ''
$after(string)
Text/HTML code to place after the link.
Default: ''

Examples

0

#1 This will display a link to the privacy policy page.

1-way

<?php the_privacy_policy_link(); ?>

The result, if the page exists:

<a class="privacy-policy-link" href="https://example.com/privacy-policy/">Privacy Policy</a>

2-way

Read the page <?php the_privacy_policy_link(); ?> before commenting. This is important!

The result, if the page exists:

Read the <a class="privacy-policy-link" href="https://example.com/privacy-policy/">Privacy Policy</a> page before commenting. It's important!

If the page is not listed or published:

Read the page before commenting. It's important!

3-way

<?php the_privacy_policy_link( 'Read the page before commenting ', '. It's important!' ); ?>

The result, if the page exists:

Read the <a class="privacy-policy-link" href="https://example.com/privacy-policy/">Privacy Policy</a> page before commenting. It's important!

If the page is not set or published, nothing will be displayed.

0

#2 Sample code for theme integration

With function_exists() test to avoid fatal error on previous WordPress versions.

<?php
if ( function_exists( 'the_privacy_policy_link' ) ) {
	the_privacy_policy_link( '<div class="privacy-policy-link-wrapper">', '</div>' );
}
?>

HTML output example (the permalink and the anchor will be dynamically generated):

<div class="privacy-policy-link-wrapper">
	<a class="privacy-policy-link" href="https://example.com/privacy-policy/">Privacy Policy</a>
</div>

Changelog

Since 4.9.6 Introduced.

the_privacy_policy_link() code WP 6.8.3

function the_privacy_policy_link( $before = '', $after = '' ) {
	echo get_the_privacy_policy_link( $before, $after );
}