Piter is right, don’t use query_posts
.
You could do something like:
$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
);
$query = new WP_Query( $args );
Just make sure you have the values right for your post_type
and meta_key
params. I.e, I use an underscore for all my meta keys: _properties
.
I have a nearly identical query running on a client’s project here: http://centerpoint.com/properties/?pgd=1&v=list&filter=1&list_type=all&sortby=city
Related Posts:
- How do I query a custom post type with a custom taxonomy?
- Get the ID of the latest post
- Using meta_query, how can i filter by a custom field and order by another one?
- Return all custom meta data for one custom post type
- Display Custom Post Type Fields
- Querying custom posts and regular posts
- Using Offset in Custom Post Type Query
- Posts per Page on custom Taxonomy Template
- Using Query Posts With Multiple Post Types And A Taxonomy
- How to get the parent’s taxonomy?
- Loading post content in FancyBox
- Query posts by custom post type and custom taxonomy
- ascending order custom post type
- Query not returning CPT posts
- Post Rank on Single Post page based on custom field
- How to get only one category of custom post type?
- Used with meta_query in query_posts works slowly
- Unable to display multiple post types in same query (WPML WP_Query)
- How to get current post id of a custom post type in a loop using template singel-{custom type}.php?
- Quickest way to get last or oldest post date – WP Query
- How to display recent posts added in several custom post types
- ‘category__and’ for custom taxonomy?
- Post the content of a specific “Custom Post Type” post within a post using a shortcode
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- List custom post type by custom tax term as page title
- query_posts with a custom post type, a meta_query and sorting by post date?
- Custom query shows custom post types in trash
- Combine query_posts() and get_posts() into single query
- how can i get posts from custom post type particular taxonomy category
- Setting posts per page in query_posts
- How to insert content from another Custom Post type into Post?
- Query/list all terms and their custom post count
- Display only one post each WEEK
- How to query_post custom posts within default taxonomy?
- How to use custom taxonomies to reference complex relationships?
- Query Custom posts of same taxonomy as the post itself
- get custom post type
- Polylang non-default language ignores tags in WP_Query
- How to edit this code to get the categories in achieve page?
- Category with post type pagination returns 404
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Limit the post for differents custom post type in the same wp_query
- Different Ways to Query Custom Post Types?
- Custom post type archive page for multiple post types
- Listing all term items alphabetically / sorting loop
- How to display Related Posts based on number of taxonomy terms matched
- How to show only the most recent post on my custom post type archive?
- How to make WP_Query not to show irrelevant posts?
- What is the ID parameter for custom post types in query_posts?
- Loop for custom post types filtered by a taxonomy
- How to limit post per page of custom post type?
- Display custom posts randomly in custom taxonomy archive
- Querying multiple values from a single key
- Not able to export large no. of posts in csv
- Pagination not working on custom query on a page
- Loop through posts of only 2 statuses
- find custom post type post by searching its custom field with my string
- FacetWP paging custom wp_query
- Can’t change posts per page in WordPress Post Type Query
- Best way to create a search for custom post type by custom field values
- Dynamic category name in query post
- List all posts in taxonomy term
- Query all post types but limit to parents
- HM CMB: Post Select Field for CPT ID
- 4 posts per page from single category
- Display Posts Query with IF function
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- Getting custom post type info using get_adjacent_post
- Custom Post Type Query W/Category Dropdown
- Query all posts under one taxonomy? Why is my code not working?
- Find Posts based on Child Post value
- Query for bbPress replies to current topic?
- Showing only posts from the current user who is logged in?
- Why can’t I query more than 1 post type at a time?
- WP query_posts group by meta field related
- custom post type and a “sticky” position taxonomy
- Create a post automatically if search result has zero results
- Limit custom post type to the authors only on front-end!
- Posts per Page on custom Taxonomy Template
- Order Posts in Custom Order
- Use WP pagination functions on a custom page template
- Getting Custom Posts with Custom Taxonomy
- Query the title of the page to show posts with matching category in the loop
- How to Create movie schedule by custom post type query
- How do I get the posts from single page custom post type from a sidebar to display in a page?
- Main site single-property.php design, as homepage of a multisite
- WordPress custom post type
- How to get main div html to print a list of posts inside?
- WordPress custom post type queries
- Using $seed on a custom post type for randomly displayed posts
- Query Distinct Taxonomies of Custom Post Type
- Advanced Custom Fields: query posts filtered by multiple field values
- What’s the best way to show custom post types? With page template it’s not perfect!
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- Inserting two categories
- How do I correctly query posts from a post ID?
- How to exclude certain portfolios from a loop
- How to get Custom post type by related category ID
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- Assign a tag to custom post type using a query