I have 2 (Wordpress) blogs on the same 开发者_StackOverflow中文版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!Let's say, you have blog at:
- http://example.com/ which resides on
/home/username/example.com/
- http://example12.com/ which resides on
/home/username/example12.com/
and you have landing page at:
- http://example31.com/ which resides on
/home/username/example31.com/index.php
You will need to create 2 files:
- /home/username/example31.com/index.php
- /home/username/example31.com/index_test_wordpress.php
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:
- I use
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. - For simplicity's sake, I only put
print_r($posts)
. But, you should get the idea.
精彩评论