WordPress get_the_privacy_policy_link() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Returns a link

Definition

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().

Syntax

Return the link, then print it.

WordPress
<?php echo get_the_privacy_policy_link(); ?>
CallWhat 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.

Full declaration
WordPress
get_the_privacy_policy_link( string $before = '', string $after = '' ): string

Parameters

ParameterDescription
$beforestring. HTML added before the link. Default is empty.
$afterstring. HTML added after the link. Default is empty.

Return Value

Return ValueDescription
stringAn a tag with the class privacy-policy-link, or an empty string if no policy page is set.

WordPress Examples

Three short examples. Each one shows the code and what it prints or does.

Example 1 — Print the Privacy Policy link

Echo the returned link.

WordPress
<?php
echo get_the_privacy_policy_link();

How It Works

  1. The function finds the page chosen in Settings.
  2. It builds an a tag with the page title as text.
  3. echo prints it.

Example 2 — Wrap the link in a span

Use the two arguments to add HTML around the link.

WordPress
<?php
echo get_the_privacy_policy_link( '<span class="footer-privacy">', '</span>' );

How It Works

  1. The first value goes before the link.
  2. The second value goes after the link.
  3. If there is no policy page, the span is not printed.

Example 3 — Use it inside a sentence

Store the link first and print the sentence only if a link exists.

WordPress
<?php
$link = get_the_privacy_policy_link();
if ( $link ) {
  echo '<p>Read our ' . $link . '.</p>';
}

How It Works

  1. We keep the returned link in $link.
  2. If it is empty, nothing is printed.
  3. Otherwise the link is placed in the sentence.

Frequently Asked Questions

It returns the HTML link to your site's Privacy Policy page.
Go to Settings, then Privacy, choose a page, and publish it.
No policy page is selected, or the selected page is not published.
get_the_privacy_policy_link() returns the HTML. the_privacy_policy_link() prints it.
No. The link is already escaped by WordPress.

Next: home_url()

Return the home URL of the current site, with an optional path.

home_url() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful