Skip to main content
Cookbook Content Envira Gallery

Put an Envira Gallery on a Page with AI

An Envira gallery you already have, placed on a new draft page or at the end of a draft post.

Difficulty Beginner
Time ~5 min

Prerequisites

A site connected to WPVibe running Envira Gallery 1.17.0 or newer (free) on WordPress 6.9 or newer, with an administrator account. To publish a draft gallery, Allow AI to edit galleries is turned on under Envira Gallery, Settings, AI & MCP.

The prompt
My WordPress site uses Envira Gallery. Put my [gallery name] gallery on [a new draft page called page title, or the end of my draft post or page called title].

1. Run discover_abilities with category envira-gallery. If the Envira Gallery abilities are not there, stop and tell me to install the free Envira Gallery plugin or update it to 1.17.0 or newer (it needs WordPress 6.9 or newer).
2. Run envira-gallery/list-galleries with search set to words from the gallery name and status any. If several match, show them with their photo counts and ask which one. If none match, run it again without search and show me the list. Then run envira-gallery/get-gallery with its id. If image_count is 0, tell me an empty gallery shows nothing anywhere and ask whether to go on.
3. Check where it goes before changing anything. For a new page there is nothing to check. For a post or page I named: find it with rest_api GET /wp/v2/posts and GET /wp/v2/pages with search set to its title, status draft,pending,publish,private,future, context edit and _fields id,title,status,link,content.raw; if several match, ask. If its status is not draft, change nothing: tell me it is not a draft (live, scheduled, waiting for review or private) and offer a new draft page instead. If content.raw is not empty and has no block comments (wp:), or holds page builder markup such as et_pb_, vc_ or wp:divi/, it was made with the classic editor or a page builder such as Elementor, Divi or WPBakery, which this recipe does not edit: change nothing and tell me to place the gallery there myself (with the builder's own element, or the envira-gallery shortcode in the classic editor). If content.raw is empty, ask whether it was built with a page builder (some, such as Bricks, Oxygen or Breakdance, keep the layout elsewhere) and go on only if I say no. If content.raw already holds the envira-gallery shortcode with this gallery's id or slug, change nothing and tell me it is already there.
4. If the gallery's status is not publish, tell me its status and that only a published gallery shows to visitors, even on a published page (I still see it while signed in, so I should check in a private window); if it is private, tell me publishing shows it to everyone. Find where the gallery is shown: run rest_api GET /wp/v2/pages and GET /wp/v2/posts, each with search envira-gallery, status publish,draft,private,pending,future, context edit, per_page 100 and _fields id,title,status,link,content.raw (if 100 come back, ask for page 2). If a response says it was cut (truncated), lower per_page and read the rest; a post still cut at per_page 1, read alone with rest_api GET /wp/v2/pages/ID (or posts) with context edit, _fields id,status,content.raw and max_length 4000000. A post shows the gallery when its content has the envira-gallery shortcode with id set to GALLERY_ID (in double, single or no quotes; Envira's own block saves the shortcode inside it) or with slug set to the gallery's slug. This does not see galleries on other content types, such as products or courses, in synced patterns, or placed with a page builder widget, a theme template or a sidebar widget. Tell me where else it is shown, because those places show it as soon as it is published, then ask whether to publish it. On my yes, run envira-gallery/describe-gallery-schema; if writes_enabled is false, tell me to turn on Allow AI to edit galleries under Envira Gallery, Settings, AI & MCP and stop. Otherwise run envira-gallery/update-gallery with the id and status publish, and nothing else. On my no, place it anyway and tell me it shows nothing until the gallery is published.
5. The gallery goes in as a Shortcode block (the block comment wp:shortcode) holding the envira-gallery shortcode with id="GALLERY_ID" inside square brackets. For a new page: rest_api_write POST /wp/v2/pages with the title, status draft and that block as content. For the draft from step 3: read it again on its own with rest_api GET /wp/v2/posts/ID (or /wp/v2/pages/ID) with context edit, _fields id,status,content.raw and max_length 4000000, because a list or a read without max_length can come back cut. If this answer says it was cut (TRUNCATED), change nothing and tell me. If its status is no longer draft, stop and tell me. Run the content checks from step 3 again on this whole read. If its content is empty, save the block as its content with rest_api_write POST to that post or page with content only. Otherwise add the block at the end without sending the whole content back: rest_api_write POST /wpvibe/v1/content/edit with target_type post, post_id ID, field post_content, old_content set to the end of the draft copied character for character (its last block comment, a closing one or one that ends with a slash, together with the text just before it), and new_content set to that same text followed by two line breaks and the Shortcode block. If it answers multiple_matches, include more of the text before it; if no_match, copy it again exactly from the read. If the route does not exist (rest_no_route), change nothing and tell me to update the WPVibe plugin. Never save the whole content back.
6. Run rest_api GET on the page or post with context edit, _fields id,status,content.raw and max_length 4000000, and confirm the content holds the shortcode once with the right id and, for an existing draft, that everything in the step 5 read is still there unchanged; if anything changed, tell me at once and that the previous version is under Revisions in the editor. Give me the link to edit it, tell me to reload it first if I have it open in the editor (saving the old copy would remove the gallery), and tell me the gallery appears when I publish it.
Already connected?

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

Run the “Put an Envira Gallery on a Page with AI” recipe from the WPVibe cookbook on my connected site.

You built a gallery in Envira, and now it needs a home: a new page, or the draft post you are writing. That means copying its shortcode or finding its block, and remembering that a gallery left as a draft shows nothing, so finished galleries never make it onto the site.

Name the gallery and where it goes. The AI finds the gallery, tells you if it is empty or still a draft and publishes it only after your yes, and adds it to a new draft page, or at the end of a draft post or page you name, keeping everything already there. It reads the page back so you can check it before you publish.

The AI only changes draft pages and posts. If the one you name is already published, scheduled or waiting for review, it changes nothing there and offers a new draft page instead, so nothing goes live before you look at it. The recipe works with the block editor; with the classic editor or a page builder, it tells you how to place the gallery yourself. To make a gallery from scratch, use this recipe.

Outcome

The gallery sits on a draft page or post, published if you said yes, and shows once you publish that page or post, with the rest of the draft unchanged.