I need to use only wp_posts from another wordpress db

0

I have 2 sites with different themes in wordpress:

Site 01: MAIN

Site 02: Secondary

I need the 02 site to access the database of site 01 and get the posts there. (I need 02 to access the database of site 01 and get posts from there always)

I do not know how to do this, any suggestions?

    
asked by anonymous 23.08.2018 / 01:40

1 answer

0

Unless you have a good excuse to load the DB directly, use the REST API native to WordPress:

For example:

GET https://site01.teste/wp-json/wp/v2/posts

or

$posts = wp_remote_get( 'https://site01.teste/wp-json/wp/v2/posts', $args );

Return the most recent articles from site01, the same content that would default to your main page.

    
27.08.2018 / 19:34