• Hi Friends,

    I have two different types of custom post types those are linked with meta data. Now my query is i need posts from one custom post type with meta-query of metakey and value order by another custom post type name which are both linked with a metakey. please someone help me in this.

    Thanks.
    Srikanth

Viewing 1 replies (of 1 total)
  • First off, you really should not be using the Post Title as metadata to query or sort on. You should be displaying the Post Title for the user to click but saving the Post ID to the database. Post IDs are unique and do not change, Post Titles and Post Slug could be changed by the client at any time they want and it would mess up your query.

    Now, if you want to sort on a meta value we can see in the WP_Query orderby docs it accepts meta_value as a parameter. It would look like this:

    'orderby' => array( 'meta_value' => 'ASC' )

Viewing 1 replies (of 1 total)
  • The topic ‘Orderby Custom Posttype title’ is closed to new replies.