I am trying to loop posts outside of WordPress installation but for some reason I am getting 500 - include(Requests.php): failed to open stream: No such file or directory error.

Here is how my code looks:

                require($_SERVER['DOCUMENT_ROOT'] . '/blog/wp-load.php'); 
                $args = array(                      
                    'posts_per_page' => 10
                $latest_posts = new WP_Query( $args );  
                if ( $latest_posts->have_posts() ) {
                    while ( $latest_posts->have_posts() ) {
                        $latest_posts->the_post(); ?>
                    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> 
                <?php if ( has_post_thumbnail() ) { ?>
                        <span class="post_thumbnail"><?php the_post_thumbnail(); ?></span>
                <?php } ?>
                        <span class="post_title"><?php the_title(); ?></span>
                    <span class="post_time">Posted on <?php the_time('l jS F, Y') ?></span>
                    <?php the_excerpt(); ?>
            <? } 
                    } else {
                    echo '<p>There are no posts available</p>';

Am I missing something here?

  • Have you thought about using the rest API to read posts? Oct 21, 2016 at 14:17

1 Answer 1


The error is related to a file called Requests.php, that is not a WordPress file. I don't see an include or require for this file in your code.

Eventually you can add this before require, and check for the wp-load.php path

define( 'WP_USE_THEMES', false );

But, do this, will not solve the error, may you add the code where Request.php appears ?

  • I am trying to loop inside Yii Framework so many be that is the issue?
    – Kevin S
    Oct 21, 2016 at 14:50
  • Maybe but it is an error between where the present file is load and where the assets are. You have to correct their path otherwise your script couldn't stream them.
    – Benoti
    Oct 21, 2016 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.