Example 1 — Print the Privacy Policy link
Echo the returned link.
<?php
echo get_the_privacy_policy_link(); How It Works
- The function finds the page chosen in Settings.
- It builds an
atag with the page title as text. echoprints it.

In WordPress, get_the_privacy_policy_link() returns the HTML link to your Privacy Policy page. You pick that page in Settings > Privacy.
If no policy page is set, or the page is not published, it returns an empty string. Use it when you want to store the link or place it inside your own text. To print the link at once, use the_privacy_policy_link().
Return the link, then print it.
<?php echo get_the_privacy_policy_link(); ?> | Call | What it does |
|---|---|
get_the_privacy_policy_link() | The link, with no extra HTML. |
get_the_privacy_policy_link( '<span>', '</span>' ) | The link wrapped in your own HTML. |
$link = get_the_privacy_policy_link(); | Store the link in a variable to check it first. |
It returns the HTML. The URL inside is already escaped.
get_the_privacy_policy_link( string $before = '', string $after = '' ): string | Parameter | Description |
|---|---|
$before | string. HTML added before the link. Default is empty. |
$after | string. HTML added after the link. Default is empty. |
| Return Value | Description |
|---|---|
| string | An a tag with the class privacy-policy-link, or an empty string if no policy page is set. |
Three short examples. Each one shows the code and what it prints or does.
Echo the returned link.
<?php
echo get_the_privacy_policy_link(); a tag with the page title as text.echo prints it.Use the two arguments to add HTML around the link.
<?php
echo get_the_privacy_policy_link( '<span class="footer-privacy">', '</span>' ); Store the link first and print the sentence only if a link exists.
<?php
$link = get_the_privacy_policy_link();
if ( $link ) {
echo '<p>Read our ' . $link . '.</p>';
} $link.Return the home URL of the current site, with an optional path.
8 people found this page helpful