Make WordPress Core

#46246 closed defect (bug) (duplicate)

get_rest_url() depends depends on get_home_url()

Reported by: pscibisz Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.0.3
Component: REST API Keywords:
Focuses: Cc:


In the get_rest_url() function, the function get_home_url() is used to build the rest api address, not get_site_url (). This makes it impossible to use wordpress as a CMS on one domain and displaying a fornt on another domain using API communication.

Change History (4)

#1 @swissspidy
16 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there and welcome to Trac!

To me this sounds like a duplicate of #37020. See also #42869.

tl;dr using the home URL is intentional.

You can use the rest_url filter to customize the returned value of the get_rest_url() function if needed.

#2 @pscibisz
16 months ago

rest_url don't work if I want to translate url (WP as multisite)
WP_SITE wp.dev.me/resources (Wordpress)
WP_HOME www.dev.me (Laravel)

Permalink: /resources/{post_name}

Then I can translate permalink in polylang:

resources => en
resources-pl => pl

In edit post I see
www.dev.me/resources/POST_NAME or www.dev.me/resources-pl/POST_NAME

WP REST API don't work on url wp.dev.me/resources/wp-json
WP search API on url www.dev.me/resources/wp-json

Last edited 16 months ago by pscibisz (previous) (diff)

#3 @pscibisz
16 months ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

#4 @swissspidy
16 months ago

  • Resolution set to duplicate
  • Status changed from reopened to closed

That sounds like an issue specific to Polylang to me. Have you contacted the plugin author already about this?

As for the specific REST URL issue about using the site URL, please comment on the original ticket #37020 so that we can keep the discussion at one place.

There's no need to reopen closed tickets just for discussion; discussion can happen on closed tickets too.

Note: See TracTickets for help on using tickets.