You ask about creating a single post, but I think you mean serving a single post that resides on the other site.
There shouldn’t be relative links in WP, they’ll surely fail with certain requests. When you display a post from another site, its links should be absolute, so a link to the single post would normally take one back to the original site on which the post exists.
If you want the remote posts to be served from your small site, you’ll need to alter the links for the posts to lead to something your site knows how to process. The current page already got the post from the initial API request. You could have the page’s scripts display the full single post in an element on the current page. This is often presented as a sidebar list of posts. The main page area might first display the first post’s content. When someone clicks on another sidebar link, script replaces the original main area content with that of the clicked post.
If you’d rather mimic normal behavior where the single post is served on a separate page, you’d need a special page template which gets passed the post ID. The template code can then request the post on the other site through another API call.
@bcworkz Thank you! yes, exactly I want to serve them from my website. Your idea sounds good, but I still want to have /blog/slug when accessing the single post. Is there a way I can altern single.php to make it work?
Or shall I create a new template for that?
Don’t directly alter single.php, that would conflict with your blogging element. Add a new custom page template which contains the necessary PHP code. You can start with a copy of single.php in order to use your theme’s DOM structure, but alter where the post data comes from. Add a new WP page that will use this template.
When you add custom templates, it’s best to use a child theme to contain your custom work.
@bcworkz Thank you, I actually already created a custom template, which takes the query var from a function which adds a rewrite_rule add_rewrite_rule( 'blog/(.+?)/?$', 'index.php?post_slug=$matches[1]', 'top' );
. And based on this query var I make a request to my bigger blog and display the content.
I’m not sure how actually correct this is based on wordpress codex, but it works ๐
Thank you for your suggestions ๐