Reputation: 4492
I have 2 (Wordpress) blogs on the same server and a landing page with 2 images.
One goes to first blog, the next one to the second blog.
Is there any way I can get in the first image, the post-thumbnail and link from the first post from the first blog and same thing from the second blog for the other image?
Thank you!
Upvotes: 0
Views: 812
Reputation: 21979
Let's say, you have blog at:
/home/username/example.com/
/home/username/example12.com/
and you have landing page at:
/home/username/example31.com/index.php
You will need to create 2 files:
And both will have code, something like this:
on your /home/username/example31.com/index.php
, write:
<?php
echo file_get_contents('http://example31.com/index_test_wordpress.php');
require_once("/home/username/example12.com/wp-load.php");
echo str_repeat("<br />", 10);
$posts = wp_get_recent_posts( array('numberposts'=>1, 'post_status'=>'publish') );
print_r($posts);
?>
on your /home/username/example31.com/index_test_wordpress.php
, write:
<?php
require_once("/home/username/example.com/wp-load.php");
$posts = wp_get_recent_posts( array('numberposts'=>1, 'post_status'=>'publish') );
print_r($posts);
?>
Note:
file_get_contents
to that file because I can't figure out a way to do two require() to wp-load.php, without conflicting each functions.print_r($posts)
. But, you should get the idea.Upvotes: 1