0

I've got this theme where you can add posts of type "portfolio", and I want to be able to reorder them up. I've added a custom meta field called "position" and I've set already those values. All good.

My question is: How can I modify the query to join the wp_postmeta table and order them by the "postion" value?

This is the current query:

$loop = new WP_Query( array(
    'post_type' => 'portfolio',
    'posts_per_page' => $homepagenumber
) );

I really appreciate any hint on this. Thanks a lot.

1

Check WP_Query Order by Parameters

 $args = array(
   'post_type' => 'my_custom_post_type',
   'meta_key' => 'age',
   'orderby' => 'meta_value_num',
   'order' => 'ASC',
   'meta_query' => array(
       array(
           'key' => 'age',
           'value' => array(3, 4),
           'compare' => 'IN',
       )
   )
 );
 $query = new WP_Query($args);
  • 1
    Thanks a lot! PS.-I tried voting your answer up but I couldn't :( (need some reputations points) – Teknotica Feb 7 '13 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.