两个WordPress博客相互调用相关文章代码。
WordPress博客调用另一个WordPress博客相关文章的代码。
在被调用的网站新建的一个php文件,放到网站的根目录。把下面代码放到新建的php文件,并且重新命名logoyuan-diqu.php(自己决定)。其中showposts=3&cat=2——3是文章的数量;2是文章分类的id
被调用的网站代码
<?php
// Include WordPress
define('WP_USE_THEMES', false);
require('./wp-load.php');
query_posts('showposts=3&cat=2');
?><?php while (have_posts()): the_post(); ?>
<li><a href="<?php the_permalink() ?>" target="_blank" ><img src="<?php index_thumbnail(); ?>" width="45" height="36" alt="<?php the_title(); ?>"/></a>
<h3><a href="<?php the_permalink() ?>" target="_blank" ><?php the_title(); ?></a></h3>
</li>
<?php endwhile; wp_reset_query();?>
展示网站的代码
<?php
//把下面的地址改为你想引用的博客地址
$url="http://vi.logoyuan.com/logoyuan-diqu.php";
echo file_get_contents( $url );
?>