Cyprus106
Cyprus106

Reputation: 5780

Wordpress run simple query_posts and BLANKS out rest of page

I am simply baffled by this. It worked before, and I look today and it's broken. Basically, this is a mobile site, and I made a very compact version of the wordpress site. Let me reiterate that it worked for months and now it seemingly randomly doesn't. I'm using this simple query_posts function below and it simply stops the page dead in it's tracks. It doesn't return an error or anything. I look at the source and the entire page just blanks out after query_posts(). There's nothing. I thought maybe it wasn't loading wordpress guts for some reason, but I run another function like wp_reset_query and it passes just fine. Furthermore, I have this exact same code running on a nearly identical site and it works fine. I've been pulling my hair out for two days and I'v exhausted everything I can think of. ANY help would be extremely appreciated

/* @package MusicScene Mobile
 * @subpackage NWMS
 */

require_once('../wp-load.php');

global $post;
wp_reset_query();
query_posts(array(
            'posts_per_page' => 5,
            'post_status' => 'publish'          
        ));

Upvotes: 0

Views: 427

Answers (3)

Prasanth Parameswaran
Prasanth Parameswaran

Reputation: 33

In case you haven't already done this: disable all plugins/roll back any updates. Since it used to work for months earlier, I do not think of any other possibility other than plugin issues. You might want to check your error log file too.

Upvotes: 1

mjsa
mjsa

Reputation: 4399

Here you go!:

     /* @package MusicScene Mobile
     * @subpackage NWMS
     */
    require_once('../wp-config.php');
    require_once('../wp-load.php');

    global $post;
    wp_reset_query();
    query_posts(array(
                'posts_per_page' => 5,
                'post_status' => 'publish'          
            ));
    wp_reset_query();

Upvotes: 3

Vlad.P
Vlad.P

Reputation: 1464

You need to include /wp-config.php as well.

require_once('../wp-config.php');

Also, wp_reset_query(); should be added after the query is made: http://codex.wordpress.org/Function_Reference/wp_reset_query

Upvotes: 0

Related Questions