Title: Themes and user privacy
Published: 7 June 2024
Last modified: 31 July 2024

---

[Home](https://learn.wordpress.org)[Courses](https://learn.wordpress.org/courses/)
[Intermediate Theme Developer](https://learn.wordpress.org/course/intermediate-theme-developer/)
Themes and user privacy

 [ Exit Course ](https://learn.wordpress.org/course/intermediate-theme-developer/)

 1.   a.  [   Global theme settings  ](https://learn.wordpress.org/lesson/global-theme-settings/)
         [Preview](https://learn.wordpress.org/lesson/global-theme-settings/)
      b.  [   Block theme styles  ](https://learn.wordpress.org/lesson/block-theme-styles/)
         [Preview](https://learn.wordpress.org/lesson/block-theme-styles/)
      c.  [   Templates  ](https://learn.wordpress.org/lesson/custom-templates/) [Preview](https://learn.wordpress.org/lesson/custom-templates/)
      d.  [   Theme Patterns  ](https://learn.wordpress.org/lesson/theme-patterns/) [Preview](https://learn.wordpress.org/lesson/theme-patterns/)
      e.  [   Style Variations  ](https://learn.wordpress.org/lesson/style-variations/)
         [Preview](https://learn.wordpress.org/lesson/style-variations/)
 2.   5 lessons
 3.   a.  [   Template overview  ](https://learn.wordpress.org/lesson/template-overview/)
         [Preview](https://learn.wordpress.org/lesson/template-overview/)
      b.  [   Template Hierarchy  ](https://learn.wordpress.org/lesson/template-hierarchy/)
         [Preview](https://learn.wordpress.org/lesson/template-hierarchy/)
      c.  [   Template parts  ](https://learn.wordpress.org/lesson/template-parts-4/) 
         [Preview](https://learn.wordpress.org/lesson/template-parts-4/)
 4.   3 lessons
 5.   a.  [   Custom functionality  ](https://learn.wordpress.org/lesson/custom-functionality/)
         [Preview](https://learn.wordpress.org/lesson/custom-functionality/)
      b.  [   Including assets  ](https://learn.wordpress.org/lesson/including-assets/)
         [Preview](https://learn.wordpress.org/lesson/including-assets/)
      c.  [   Block stylesheets  ](https://learn.wordpress.org/lesson/block-stylesheets/)
         [Preview](https://learn.wordpress.org/lesson/block-stylesheets/)
      d.  [   Block style variations  ](https://learn.wordpress.org/lesson/block-style-variations/)
         [Preview](https://learn.wordpress.org/lesson/block-style-variations/)
      e.  [   Block variations  ](https://learn.wordpress.org/lesson/block-variations/)
         [Preview](https://learn.wordpress.org/lesson/block-variations/)
 6.   5 lessons
 7.   a.  [   Introduction to Classic themes  ](https://learn.wordpress.org/lesson/introduction-to-classic-themes/)
         [Preview](https://learn.wordpress.org/lesson/introduction-to-classic-themes/)
      b.  [   The Loop  ](https://learn.wordpress.org/lesson/the-loop/) [Preview](https://learn.wordpress.org/lesson/the-loop/)
      c.  [   Theme options  ](https://learn.wordpress.org/lesson/theme-options/) [Preview](https://learn.wordpress.org/lesson/theme-options/)
      d.  [   theme.json in Classic themes  ](https://learn.wordpress.org/lesson/theme-json-in-classic-themes/)
         [Preview](https://learn.wordpress.org/lesson/theme-json-in-classic-themes/)
      e.  [   Converting a Classic theme to a Block theme  ](https://learn.wordpress.org/lesson/converting-a-classic-theme-to-a-block-theme/)
         [Preview](https://learn.wordpress.org/lesson/converting-a-classic-theme-to-a-block-theme/)
 8.   5 lessons
 9.   a.  [   Best practices for developing an accessible theme  ](https://learn.wordpress.org/lesson/best-practices-for-developing-an-accessible-theme/)
         [Preview](https://learn.wordpress.org/lesson/best-practices-for-developing-an-accessible-theme/)
      b.  [   Tools for testing theme accessibility  ](https://learn.wordpress.org/lesson/tools-for-testing-theme-accessibility/)
         [Preview](https://learn.wordpress.org/lesson/tools-for-testing-theme-accessibility/)
 10.  2 lessons
 11.  a.  [   Themes and user privacy  ](https://learn.wordpress.org/lesson/themes-and-user-privacy/)
         [Preview](https://learn.wordpress.org/lesson/themes-and-user-privacy/)
 12.  1 lesson
 13.  a.  [   Child themes  ](https://learn.wordpress.org/lesson/child-themes/) [Preview](https://learn.wordpress.org/lesson/child-themes/)
      b.  [   UI Best Practices  ](https://learn.wordpress.org/lesson/ui-best-practices/)
         [Preview](https://learn.wordpress.org/lesson/ui-best-practices/)
      c.  [   JavaScript in Themes  ](https://learn.wordpress.org/lesson/javascript-in-themes/)
         [Preview](https://learn.wordpress.org/lesson/javascript-in-themes/)
      d.  [   Build Process  ](https://learn.wordpress.org/lesson/build-process/) [Preview](https://learn.wordpress.org/lesson/build-process/)
      e.  [   Plugin API hooks  ](https://learn.wordpress.org/lesson/plugin-api-hooks/)
         [Preview](https://learn.wordpress.org/lesson/plugin-api-hooks/)
      f.  [   Testing your theme  ](https://learn.wordpress.org/lesson/testing-your-theme/)
         [Preview](https://learn.wordpress.org/lesson/testing-your-theme/)
 14.  6 lessons
 15.  a.  [   The WordPress.org Theme Directory  ](https://learn.wordpress.org/lesson/the-wordpress-org-theme-directory/)
         [Preview](https://learn.wordpress.org/lesson/the-wordpress-org-theme-directory/)
      b.  [   Required theme files  ](https://learn.wordpress.org/lesson/required-theme-files/)
         [Preview](https://learn.wordpress.org/lesson/required-theme-files/)
      c.  [   Preparing your theme for submission  ](https://learn.wordpress.org/lesson/preparing-your-theme-for-submission/)
         [Preview](https://learn.wordpress.org/lesson/preparing-your-theme-for-submission/)
      d.  [   Submitting your theme to WordPress.org  ](https://learn.wordpress.org/lesson/submitting-your-theme-to-wordpress-org/)
         [Preview](https://learn.wordpress.org/lesson/submitting-your-theme-to-wordpress-org/)
      e.  [   Updating your theme  ](https://learn.wordpress.org/lesson/updating-your-theme/)
         [Preview](https://learn.wordpress.org/lesson/updating-your-theme/)
 16.  5 lessons

### Privacy

# Themes and user privacy

As the internet has evolved, so have the ways in which user privacy is protected.

In this lesson, you’ll discover how themes can impact user privacy and what you 
can do to ensure that your theme respects this privacy.

## Internet privacy

Various laws and regulations around the world govern how websites can collect and
use personal data.

These laws require companies and site owners to be transparent about how they collect,
use, and share personal data.

They also give individuals more access and choice when it comes to how their own
personal data is collected, used, and shared.

In [version 4.9.6](https://wordpress.org/news/2018/05/wordpress-4-9-6-privacy-and-maintenance-release/),
WordPress introduced various privacy-related features, primarily to help site owners
comply with the European Union’s General Data Protection Regulation (GDPR).

The main features introduced in WordPress 4.9.6 included an option to set a Privacy
Policy page, a way for users interacting with a site via comments to exclude their
personal information from being captured, and tools that site admins can use to 
better handle users’ personal information.

Of these features, the Privacy Policy page and the comment data handling are the
most relevant to theme developers.

## Privacy Policy page

The Privacy Policy page feature allows site owners to create a Privacy Policy page
that explains how their site collects, uses, and shares personal data. This page
is automatically created in draft status on new WordPress installs.

Site owners can edit and publish the page, and then the page can then be configured
as the privacy page under **Settings > Privacy**.

As a theme developer, you can help site owners by providing a way to link to the
Privacy Policy page from the theme.

This can be done by adding a link to the Privacy Policy page in the footer or by
adding a Privacy Policy link to the site’s main menu.

There are a couple of ways to add a Privacy Policy link to a theme.

You can use the following PHP functions:

 * [get_privacy_policy_url()](https://developer.wordpress.org/reference/functions/get_privacy_policy_url/):
   Retrieves the URL to the Privacy Policy page.
 * [the_privacy_policy_link()](https://developer.wordpress.org/reference/functions/the_privacy_policy_link/):
   Displays the Privacy Policy page link with formatting, when applicable.
 * [get_the_privacy_policy_link()](https://developer.wordpress.org/reference/functions/get_the_privacy_policy_link/):
   Returns the Privacy Policy page link with formatting, when applicable.

For example, the following code would display a Privacy Policy link in a div:

    ```php
    <?php the_privacy_policy_link( '<div>', '</div>' ); ?>
    ```

There are currently no core blocks for adding a Privacy Policy link in the Site 
Editor.

However, you could create a custom pattern that includes a link to the Privacy Policy
page.

    ```php
    <?php
    /**
     * Title: Privacy Policy Link
     * Slug: twentytwentyfour/privacy-link
     * Categories: featured
     */
    ?>
    <!-- wp:paragraph {"fontSize":"small"} -->
    <?php the_privacy_policy_link() ?>
    <!-- /wp:paragraph -->
    ```

You could then include this pattern in your theme’s available block patterns for
site admins to add if needed.

## Comment data

WordPress posts allow visitors to leave comments.

This functionality is handled by the Comment Form block in block themes and the `
comment_form()` [function](https://developer.wordpress.org/reference/functions/comment_form/)
in classic themes.

When a visitor who does not have a specific account on the site comments on a post,
they are asked for their name, email, and website.

This information is stored locally in the commenter’s browser as a browser cookie
for two purposes:

 1. If they leave another comment on the site, their name, email, and website will 
    be pre-populated into the respective fields.
 2. If their comment is held for moderation, they can return to that post and remove
    the comment before it is approved.

The information stored in this cookie is not essential for the functionality of 
the site. Therefore, the user needs to be given the choice to opt-in to the storage
of this personal information.

For this reason, WordPress outputs a checkbox under the comment form that allows
commenters to opt-in to storing this data in the cookie.

This checkbox will be unchecked by default, as opt-in is an action the user must
specifically approve.

Fortunately, this new checkbox field is automatically added to comment forms displayed
using the Comment Form block or the `comment_form()` function.

However, as a theme developer, it is important that you test your theme to ensure
that this checkbox is displayed correctly anywhere the comments form is displayed
and that it functions as expected.

## Further reading

For more information on user privacy and how themes can impact it, check out the
[Privacy](https://developer.wordpress.org/themes/advanced-topics/privacy/) page 
under Advanced Topics in the Theme Developer Handbook.

 This is a preview lesson

Register or sign in to take this lesson.

 [ Take course ](https://learn.wordpress.org/course/intermediate-theme-developer/)

 [ Sign in ](https://login.wordpress.org/?redirect_to=https%3A%2F%2Flearn.wordpress.org%2Flesson%2Fthemes-and-user-privacy%2F&locale=en_US)

##  Suggestions

 Found a typo, grammar error or outdated screenshot? [Contact us](https://learn.wordpress.org/report-content-feedback/).