Meta values and query_posts

Hi All,

So I’m stuck - I’ve trawled through the codex and tried different variations of google searches but I’ve had no luck.

Basically I’ve got a custom meta box on pages that allows me to feature the content on the front page. It has a tick box and an order field. What I’m trying to do is update the query on the front page to take acount of the order field. At the moment I’m just pulling back posts that have the existing meta key “_my_meta” (code below).

What I want to do is pull back posts that have the meta key “_my_meta”, the meta value “featured” and order them by the meta value “order” (both featured and order are stored in an array in _my_meta). Can anyone help?

$args = array(
	'post_type'  	=> array( 'post', 'page', 'news', 'llc_events' ),
	'meta_key'    	=> '_my_meta',
	'orderby'		=> 'title',
	'order'    		=> 'ASC'
);


// The Query
query_posts( $args );

Cheers,
Richard.

does this help?

Hi wellyfish,

I think it probably would however I’ve just changed orderby from title to meta_value and it works. I also changed from query_posts to WP_Query.

To be honest I’m a bit mistified as to how this is working. The order is one element in an array so I assumed that the meta_value in the code below would return both:

featured: yes
order:1

Hence why I was trying to seperate them. However WP seems to be picking up the order value and using it.

The working code:

$args = array(
	'post_type'  	=> array( 'post', 'page', 'news', 'llc_events' ),
	'meta_key'    	=> '_my_meta',
	'orderby'		=> 'meta_value',
	'order'    		=> 'ASC'
);


// The Query
$the_query = new WP_Query( $args );

Thanks for the suggestion though.