admin管理员组

文章数量:1279213

I wanted to get the Post ID of a post from another website, but it was not in the url, but it was in the Response Header.

When I output the Response Header, the Post ID does not appear on the output. Do you have a solution for getting the Post ID ?

I wanted to get the Post ID of a post from another website, but it was not in the url, but it was in the Response Header.

When I output the Response Header, the Post ID does not appear on the output. Do you have a solution for getting the Post ID ?

Share Improve this question asked Nov 15, 2021 at 19:08 markazfa irmarkazfa ir 1 2
  • 1 You might be able to use the remote site's REST API. A URL like https://example/wp-json/v2/posts/?slug=the-slug-you-want would return the post(s) with that slug, and in the post's/posts' JSON objects the ID is available. – Pat J Commented Nov 15, 2021 at 19:26
  • Really Really Thank You Mr Pat j. ♥ The solution : example/wp-json/wp/v2/posts/?slug=the-slug-you-want – markazfa ir Commented Nov 15, 2021 at 19:53
Add a comment  | 

1 Answer 1

Reset to default 2

WordPress's REST API should provide the information you need.

If you're after a post with the slug the-slug-you-want, then you can request the data about any post(s) with that slug using the URL https://example/wp-json/v2/posts/?slug=the-slug-you-want. This returns the post(s) with that slug, and in the post's/posts' JSON objects the ID is available.

本文标签: Find the Post ID of a post from another website