feat(wp-content): make the bricks_wp_* post tools work on custom post types - #15
Open
floodwayprintco wants to merge 1 commit into
Open
Conversation
All four bricks_wp_* post tools hardcoded /wp/v2/posts, which serves only the built-in post type. Every CPT 404'd with "Invalid post ID" on an id that /wp-json/wp/v2/<cpt> returns fine, which reads like a bad id and sends you hunting. On floodwayprintco.com that blocked the writing that matters most: the 25 service-area city pages keep their per-city copy in post_content, the shared furniture lives in a Bricks template, and the template was editable while the copy was not. Added an optional post_type param (REST base, default "posts") to list, get, create and update, and used it in the URL. Defaults preserve existing behaviour exactly, so nothing that works today changes. Left categories and tags alone. They're taxonomies, not post types. The REST base is discoverable rather than guessed: bricks_get_post_types already returns it per type, and the param description points there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All four
bricks_wp_*post tools hardcode/wp/v2/posts, which serves only the built-inposttype. Every custom post type comes back as:
on an id that
/wp-json/wp/v2/<cpt>/<id>returns fine. It reads like a bad id, so you go huntingfor the id rather than for the endpoint.
On the site this came from, that blocked the writing that mattered most: 25 service-area city
pages keep their per-city copy in
post_contentwhile the shared furniture lives in a Brickstemplate. The template was editable through the MCP and the copy was not.
The change
An optional
post_typeparameter (the REST base, default"posts") onlist,get,createand
update, used in the URL:The default preserves existing behaviour exactly, so nothing that works today changes. 11 lines
added, 7 changed, one file.
Notes
bricks_get_post_typesalready returnsit per type, and each param description points there.
different parameter.
show_in_restare reachable, which is the existing REST behaviour and notsomething this changes.
Branched off
main.node --checkpasses on the changed file.