Warning: Illegal string offset 'top' in /www/wwwroot/hellyhua.com/wp-content/themes/Snape/single.php on line 45
实现方法
首先,在需要被调用的 WordPress 网站的根目录下创建一个 call.php
文件(文件名可以自行修改),在文件中加入:
<?phpdefine('WP_USE_THEMES', false);require('./wp-load.php');query_posts('showposts=10');<?php while (have_posts()): the_post(); ?><li><a href="<?php the_permalink(); ?>" target="_blank"><?php echo mb_strimwidth(strip_tags(apply_filters('the_title', $post->post_title)), 0, 50," "); ?></a></li><?php endwhile; ?>
其中,query_posts('showposts=10');
是可以自行修改的,具体修改方法因 WordPress 主题和插件使用而异。在需要调用的地方(需 php 支持),添加
<?php$url="http://xxx.com/call.php";echo file_get_contents( $url );?>
其中,http://xxx.com/call.php
需要替换成被调用的 WordPress 网站下 call.php
文件的地址。
Warning: Illegal string offset 'footer' in /www/wwwroot/hellyhua.com/wp-content/themes/Snape/single.php on line 49