I have a site at the main domain and then a blog at blog.domain.com. Any way to retrieve the latest post from the blog.domain.com and echo it out on the top of my home.php file?
Not really sure where to look, many outdated examples :X
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI have a site at the main domain and then a blog at blog.domain.com. Any way to retrieve the latest post from the blog.domain.com and echo it out on the top of my home.php file?
Not really sure where to look, many outdated examples :X
Appearance >> Widgets >> Select RSS and enter any blog feed you want.
You can do it using the default rss widget in wordpress. Create a widget box to appear where you want through functions.php file in your theme.
or you can get jNewsticker from Codecanyon and enter the feed from the blog and copy the shortcode where you want it and change the css to match your theme.
Easiest way to do it now is with the WP REST API. By making a request to the site's API, you can request the most recent post data, then parse the JSON response for display on your site.
If your blog site is up-to-date, make a GET request to https://<your-blog-domain>/wp-json/wp/v2/posts?per_page=1&_embed
to get the most recently published post. For example, try https://make.wordpress.org/core/wp-json/wp/v2/posts?per_page=1&_embed to see the latest post from the WP Core dev team.