12

After the update regarding the GDPR, WordPress now has an option named "Privacy Policy" under the settings, which you can use a page to be used as your privacy policy page.

How can I get the ID or the permalink for this page to use in my theme or plugin?

2 Answers 2

15

WordPress stores the page id for the privacy policy page in the options table. To get the value, you can use:

$privacy_policy_page = get_option( 'wp_page_for_privacy_policy' );

if( $privacy_policy_page ) {
    $permalink = esc_url( get_permalink( $privacy_policy_page ) );
}

The $privacy_policy_page variable holds the ID of the privacy policy page.

1
  • You would use: if( get_the_ID() == $privacy_policy_page ) { // do something } May 2, 2019 at 14:41
14

These functions are available since 4.9.6 for the privacy policy url and link:

  • get_privacy_policy_url() - filterable with the privacy_policy_url filter.
  • get_the_privacy_policy_link() - filterable with the the_privacy_policy_link filter.
  • the_privacy_policy_link() - wrapper that outputs get_the_privacy_policy_link().

See ticket #43850

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.