I have a custom query:
<?php
query_posts(array(
'post_type' => 'properties',
'meta_key' => 'pd_city',
'orderby' => 'meta_value',
'order' => 'ASC',
'posts_per_page' => 5,
'paged' => get_query_var('paged')
));
?>
But it doesn't seem to be working. The posts on this page should be listed alphabetically by city (Burnaby, New Westminster, Richmond, Surrey), but they are listed in a random order (I'm not sure how they are being ordered).
Not sure what I'm missing. I created the 'properties' post_type via the 'Post Meta' Wordpress plugin if that makes a difference.
http://www.professionalrentals.ca/new-properties-test-page/
Attempt using WP_Query - Also DOES NOT WORK
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'properties',
'meta_key' => 'pd_city',
'orderby' => 'meta_value',
'order' => 'ASC',
'posts_per_page' => 5,
'paged' => $paged
);
$the_query = new WP_Query( $args );
?>
<?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
query_posts
. It messes up the main query, is slow, breaks page functionality, breaks pagination, and reruns queries. It is just plain evil. Usepre_get_posts
to alter the main query, or useWP_Query
orget_posts
to construct custom queries for secondary queries