Fetching latest posts from 2 different WP installations

I’d use the REST API to get the latest 10 posts from each install, then combine the two arrays, sort them by the date, and then only use the latest 10 results. $editorials = wp_remote_get( ‘https://www.example.com/editorials/wp-json/wp/v2/posts/’ ); $news = wp_remote_get( ‘https://www.example.com/news/wp-json/wp/v2/posts/’ ); $editorials = json_decode( $editorials[ ‘body’ ] ); $news = json_decode( $news[ ‘body’ ] … Read more

WP_load, shortinit for wordpress Ajax

You should be using admin-ajax.php for your AJAX requests and WordPress has pretty good wrappers and actions to help you do that. In terms of performance, 3-4s is pretty harsh. WordPress will typically serve a non-cached request in about 300ms out of the box, so some other theme or plugin is adding to that time, … Read more

wp-load.php not working

You don’t need to load wp-load.php, you can build an endpoint to poll with javascript using a REST API endpoint. In your plugin, or functions.php, we’re going to create an example endpoint, it will live at https://yoursite.com/wp-json/yourname/v1/yourendpoint, it will take in parameters, and reply with a snippet of JSON, just as you would expect from … Read more

Check user logged in from outside of WP folder

If WordPress is installed in /subfolder/, then the authentication cookies will by default only valid for that path. So if needed, you can allow the cookies in parent directory by setting the cookie constants like COOKIEPATH. For example, if I had WordPress installed at example.com/wp/ and I wanted the authentication works at example.com/, then I’d … Read more

tech