【发布时间】:2016-12-19 05:59:50
【问题描述】:
我正在尝试使用 php 在非 wordpress 网站的主页上显示最新的博客文章。
这是我的代码:
<?php require('../../../../../../../blog/wp-blog-header.php');
?>
<?php
$args = array( 'numberposts' => 3, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
$postslist = get_posts( $args );
echo '<ul id="latest_posts">';
foreach ($postslist as $post) : setup_postdata($post); ?>
<li><strong><?php the_date(); ?></strong><br />
<a href="<?php the_permalink(); ?>" title="<?php the_title();?>"> <?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
但是我收到了这个错误:
致命错误:require():需要打开失败 '../../../../../../../blog/wp-blog-header.php' (include_path='/home/devbh/public_html/app/code/local:/home/devbh/public_html/app/code/community:/home/devbh/public_html/app/code/core:/home/devbh/public_html/ lib:.:/usr/lib/php:/usr/local/lib/php') 在 /home/devbh/public_html/app/design/frontend/test1/default/template/page/hpBlog.phtml 第 35 行
我已经确定文件路径是正确的,所以这不应该是问题,但真的想不出还有什么可能吗?有什么想法吗?
【问题讨论】: