[wp-hackers] WP_Query and orderby - outside of WP

Bill Dennen dennen at gmail.com
Mon May 14 15:55:50 UTC 2012


Hi,

I have a regular PHP script that bootstraps WordPress by including
wp-load.php (as previously discussed on this list).

I'm doing something relatively simply --

a) loading WP
b) grabbing posts of a certain custom post type

I'd like to change the orderby, but no matter what I pick for orderby,
the posts come back in the same order (ie. date).

Here's my code:

--

global $wp_the_query, $wp_query, $wp_rewrite, $wp;
define('DISABLE_WP_CRON', true);
require_once('/home/wheaton/public_html/wp-load.php');
$quilts = new WP_Query('post_type=profiles&post_status=publish&orderby=rand' );
while ( $quilts->have_posts() ) : $quilts->the_post();
// etc

--

In short, changing the orderby parameter has no effect. ie. title, rand, etc.

What could be causing this? Might it have to do with bootstrapping WP
in this way?

Doc: http://codex.wordpress.org/Class_Reference/WP_Query

Thanks-
Bill


More information about the wp-hackers mailing list