Skip to main content
Cookbook Content WPConsent

Add a Cookie Policy Page with WPConsent and AI

A cookie policy page with a self-updating cookie table, reviewed as a draft and linked from your banner.

Difficulty Beginner
Time ~10 min

Prerequisites

A site connected to WPVibe running WPConsent 1.2.1 or newer (tested on 1.2.1, free) on WordPress 6.9 or newer, with an administrator account. Pages in the block editor or the classic editor.

The prompt
My WordPress site uses WPConsent. Add a cookie policy page, and let me review it before it goes live.

1. Run discover_abilities with category wpconsent-tools, then wpconsent-settings and wpconsent-cookies. If the WPConsent abilities this needs are not there, stop and tell me to install or update the free WPConsent plugin (1.2.1 or newer, on WordPress 6.9 or newer).
2. Run wpconsent/get-settings. If cookie_policy_page is not 0, run rest_api GET /wp/v2/pages/OLD_PAGE_ID with context edit. If that page exists and is not in the trash, tell me I already have one, with its link and status, and stop: creating another makes a second page. If it is a page I wrote, tell me it can show WPConsent's cookie table too if I add WPConsent's cookie policy shortcode (wpconsent_cookie_policy, in square brackets) to it. If its status is not publish, tell me visitors who click Cookie Policy in the banner's preferences panel get a page not found, and that publishing it fixes that. Otherwise (cookie_policy_page is 0, or that page is trashed or not found), run rest_api GET /wp/v2/pages with search cookie and status publish,draft,pending,private. If a page that looks like a cookie policy is there, show it and ask whether to create WPConsent's page anyway: it is a new page, and the banner will link to it instead once it is published. If I go on, remind me at the end that the old page is still public until I unpublish it.
3. Run wpconsent/list-cookies. If it lists only WPConsent's own preferences cookie, tell me the table would be nearly empty, suggest scanning my site with WPConsent first, and ask whether to go on.
4. Run run_wp_cli with option get wp_page_for_privacy_policy. If it is 0, or rest_api GET /wp/v2/pages/PRIVACY_PAGE_ID shows it is not published, tell me the new page's Privacy Policy link will be empty, and ask for my privacy policy's address or whether to drop that sentence. Also tell me about the banner's preferences panel: if wp_page_for_privacy_policy is 0, its cookie policy sentence ends with "and ."; if it points to a draft page, its Privacy Policy link leads visitors to a page not found. Both are fixed by publishing a privacy policy page and choosing it in WordPress under Settings, Privacy.
5. Tell me wpconsent/generate-cookie-policy creates the page published and links it from the banner's preferences panel at once, and that you will make it a draft and unlink it right away, so visitors never meet a draft. On my yes, run it and keep its page_id as NEW_PAGE_ID. Right away run wpconsent/update-settings with cookie_policy_page 0, then rest_api_write POST /wp/v2/pages/NEW_PAGE_ID with status draft. If either call fails, tell me at once which state the page is in (live, or a draft the banner still links to) and stop.
6. Run rest_api GET /wp/v2/pages/NEW_PAGE_ID with context edit. Keep the wpconsent_cookie_policy shortcode (or its block) exactly as it is: it draws the cookie table. If the Privacy Policy link's address is empty, set it to the address I gave, or drop that sentence, with rest_api_write. If I asked, rewrite the intro paragraph in plain words for my site: [anything to say about your site, or leave the default]. Save as a draft, don't publish.
7. Give me the page's preview link and wait. Only on my yes, run rest_api_write POST /wp/v2/pages/NEW_PAGE_ID with status publish, then wpconsent/update-settings with cookie_policy_page NEW_PAGE_ID, then run_wp_cli with cache purge so visitors get the link (a CDN in front of my site may need its own purge). If I say no or not now, leave it as an unlinked draft, and tell me that when I publish it later, the sentence to link it is: Set WPConsent's cookie policy page to NEW_PAGE_ID with wpconsent/update-settings (with the real id).
8. Tell me what you created and changed, and the page's address.
Already connected?

Skip pasting the full prompt. Drop this into your AI on a site that already has WPVibe:

Run the “Add a Cookie Policy Page with WPConsent and AI” recipe from the WPVibe cookbook on my connected site.

Your banner says “see our cookie policy”, and there isn’t one, or it’s a page you wrote years ago that lists none of the cookies your site sets now. Writing one by hand means keeping a table of cookies up to date forever.

The AI checks you don’t have one already, then has WPConsent create the page with its cookie table, which updates itself from your cookie list. It moves the page to draft right away, fixes the Privacy Policy link, adjusts the intro to your site if you want, and publishes it only on your yes.

WPConsent creates the page published and links it from the banner’s preferences panel at once, so the AI makes it a draft and unlinks it right away, then links it again when you publish. Until then the banner has no cookie policy link. The table is only as good as your cookie list: run the setup recipe first if it’s empty.

Outcome

A published Cookie Policy page with your cookie table and a working Privacy Policy link, or none, set as the banner's cookie policy.