With WordPress version 4.9.6 a number of Privacy Related Options, Hooks and Capabilities were added (predominantly in response to the EU General Data Protection Regulation (GDPR) legislation.
Specifically, a new option wp_page_for_privacy_policy
has been introduced, which stores the page id of the site’s privacy policy page.
Setting the Option
If you are running, WordPress 4.9.6 or newer, you can go to Settings > Privacy (wp-admin/privacy.php
) where you will see something like the following
Here you can select (or create) the Privacy Policy page for your website. This will populate the wp_page_for_privacy_policy
option.
Using the Option
To use this value to display the Privacy Policy URL, you can use something like
echo esc_url( get_permalink( get_option( 'wp_page_for_privacy_policy' ) ) );
a more complex example might look like
printf(
'<a href="%s">%s</a>',
get_permalink( get_option( 'wp_page_for_privacy_policy' ) ),
esc_html( __( 'Privacy Policy' ) )
);
Resources
WordPress Privacy Related Options, Hooks and Capabilities
You’re missing a closing parenthesis
Hi Jeffrey,
Good catch about the missing closing parenthesis. I’ve updated the code in this post. Thanks for your help.
The second and third parameters of the printf function should be reversed in order.
Hi Oleg,
Good catch – thank you. I’ve updated this post and corrected the order of the parameters for
prinf()
. Thanks.All well and good (found this with a search) … but what about *setting* the value?