2016-08-12 2 views
0

私は最新のブログ記事を、ワードプレスではないウェブサイトのホームページに表示しています。phpで非ワードプレスサイトのブログ記事を表示

これは私のコードです:

<?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> 

しかし、私はこのエラーを取得しています:

Fatal error: require(): Failed opening required '../../../../../../../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') in /home/devbh/public_html/app/design/frontend/test1/default/template/page/hpBlog.phtml on line 35

私はそれは問題ではありませんので、ファイルパスが正しいことを確認しましましたが、他に何ができるのか本当に考えることができないのですか?何か案は?

+0

[こちら](https://wordpress.org/support/topic/integrating-wp-in-external-php) -pages) –

+0

あなたは[xml-rpc](https://codex.wordpress.org/XML-RPC)を使用できませんか? –

答えて

0

、それがどのように動作するかをいくつかのコード例:ここでは

<?php 
// those two lines at the very top 
define('WP_USE_THEMES', false); 
require('/path/to/your/wordpress/wp-load.php'); 

// ... rest of your code like for example ... 

query_posts('showposts=1'); 
while (have_posts()): the_post(); ?> 

<h2><?php the_title(); ?></h2> 
<?php the_excerpt(); ?> 
<p><a href="<?php the_permalink(); ?>">Read more...</a></p> 

<?php endwhile; ?> 

は、いくつかの詳細との記事です:

https://wordpress.org/support/topic/display-wordpress-content-outside-of-your-blog-corvid-works

あなたのエラーが解決しない、との両方あなたのサイトが異なる仮想上で実行する場合あなたのapache設定をチェックしてください。あなたの仮想ホストがあなたの他のディレクトリにアクセスできることを確認してください(セキュリティ上の観点から、それは厄介です)

関連する問題