-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[gatsby-source-wordpress] Support non-pretty permalinks #12649
Comments
(also I think that this part of the plugin's docs can be updated: changing permalinks to anything other than Plain won't work if WordPress is hosted on a subdomain) |
There seems to have been a problem on my end, a brand new installation of WordPress on a subdomain exposes as expected the |
I am running into a similar issue with a local docker instance based on https://docs.docker.com/compose/wordpress/. localhost:8080/wp-json/ cannot be found while localhost:8080/?rest_route=/ works fine. Changing the permalink settings did not help either. |
@re1 feel free to reopen this issue if you'd like, even though it was solved for me I still think that supporting non-pretty permalinks would be a good thing 🙂 |
Thank you for the fast response 👍 It seems like I do not have permission to re-open your issue.
This is especially true as
|
Reopening 👍 |
Hi @re1! Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it. If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look. Thanks for using Gatsby! 💜 |
Hey @wardpeet! {
resolve: 'gatsby-source-wordpress',
options: {
baseUrl: process.env.WP_URL,
protocol: process.env.WP_PROTOCOL,
hostingWPCOM: false,
useACF: false,
includedRoutes: ['**/media', '**/pages', '**/posts'],
},
}, WordPress was hosted locally using Docker as described here: https://docs.docker.com/compose/wordpress/. As WordPress does not expose
Because of an issue in my docker setup pretty permalinks did not work for me, which is why this became a problem for me. WordPress itself recommends using To reproduce this issue setting up the gatsby-wordpress-starter with a local WordPress instance should be enough as non-pretty permalinks are used by default. |
I am just setting up GatsbyJS to make a new website for my podcast that uses wordpress and I ran into the same issue. Our Wordpress installation is using the non-pretty permalinks, and we can't change that without breaking our RSS feed. Anyway... since I knew what was going on here, and I'd like to continue learning and trying GatsbyJS I took a stab at fixing this. I changed the code to allow you to configure using the Non-Pretty Permalinks instead, but I honestly don't now how to build and test node_modules... |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing! Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing! Thanks again for being part of the Gatsby community! |
Any plan to support |
@shinebayar-g I guess I should take another serious look at the changes I made. As far as I could tell it doesn't seem difficult based on how I did it. I'll see if I can actually build the files and test though. Then maybe we can get someone to re-open this ticket and I can do a pull request. |
Can this issue be looked into again? We're running Wordpress as purely a rest api, in that use case adding pretty URLs doesn't make a lot of sense. I can only find two instances of wp-json in https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-wordpress/src/fetch.js but I'm not sure if there's any subtleties in there I'm missing. |
@wardpeet The assumption that let restRoute = url;
if (url.includes('/wp-json/')) {
restRoute = url.replace('/wp-json', '/?rest_route=');
}
let routeResponse = await getPages({
url: restRoute,
_perPage,
_auth,
_cookies,
_accessToken,
_verbose,
_concurrentRequests,
}) The other issue is that const getOptions = page => {
let o = {
method: `get`,
url: `${url.includes('?rest_route=') ? `${url}&` : `${url}?`}${querystring.stringify({
per_page: _perPage,
page: page,
})}`,
} This "works" but I think a new option called |
It seems to me like edit: oh, I see @magicink this is more or less what you've done. |
I'll reopen this issue because it's obviously still affecting people. @magicink I agree that a plugin option like On the other hand, adding an option exposes this setting to plugin users, and I'm not sure that it should be (users shouldn't have to care about pretty permalinks or not, especially when using WP as a headless CMS). I think a PR could actually be open if anyone feels like it, the implementation details will be easier to discuss over there. |
Hey everyone, thanks for your comments, thoughts and debugging on this. For this reason, I don't believe it's worth fixing this issue as v3 will soon be deprecated. However, if anyone would like to contribute a PR we can get that merged before v4. Thanks! |
Hey @TylerBarnes i'am trying to query custom wordpress admin menus and I found out that with the older version of |
@anicioalexandre that feature isn't currently implemented - this PR addressed it but it didn't get merged. If you want to make that same PR on the Gatsby repo instead I'm happy to review it. Closing this issue as we're not actively developing gatsby-source-wordpress v3 anymore. |
Summary
I'd like to reopen the discussion that was started in this PR last june about supporting non-pretty urls in
gatsby-source-wordpress
.As mentioned in WordPress's REST API Handbook, the typical WP API endpoint is
http://oursite.com/wp-json/
, unless we have non-pretty permalinks:This is also the case if the WordPress instance is hosted on a subdomain, for example
admin.oursite.com
.The endpoint here is
http://oursite.com/?rest_route=/
, and hittinghttp://oursite.com/wp-json/
returns a 404.Motivation
I think it makes sense to host the WordPress endpoint on a subdomain, so that editors can easily reach the CMS. For this
gatsby-source-wordpress
needs to support endpoints with query params likehttp://oursite.com/?rest_route=/
The text was updated successfully, but these errors were encountered: