Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use post_name for query instead of ID #42778

Closed
wants to merge 2 commits into from

Conversation

getdave
Copy link
Contributor

@getdave getdave commented Jul 28, 2022

This is not RfR

What?

Amends the REST API to accept a string based slug when querying for a single wp_navigation post.

Why?

See #38291 (comment).

Essentially we need the REST API to be able to find a given wp_navigation by a slug rather than a post ID. This will ultimately make Navigations more portable across different installs.

Follows a similar path to the Template Parts API.

How?

Amends the rest_controller_class for handling wp_navigation to a custom controller Gutenberg_REST_Navigation_Controller. This then overides the get_post method of the parent classes so that it queries by post_name (slug).

It also registers a new GET route which allows for using a string as the ID.

Testing Instructions

  • Enable pretty permalinks on your site
  • New tab http://localhost:8888/wp-json/wp/v2/navigation/{{POST_NAME_SLUG_OF_YOUR_NAV_POST}}
  • See Navigation details.

Screenshots or screencast

@getdave getdave added the [Block] Navigation Affects the Navigation Block label Jul 28, 2022
@getdave getdave self-assigned this Jul 28, 2022
@getdave
Copy link
Contributor Author

getdave commented Aug 1, 2022

Closing in favour of #42809

@getdave getdave closed this Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant