Using IP Metabox Plugin on WordPress i have a Metabox called ‘ipmb_metabox_4’
and the field ‘price’ is used within it.
IP Metabox (https://wordpress.org/plugins/ip-metaboxes/) uses the following code to call a Metabox/Custom Field Value.
<?php $values = ipmb_get_metabox_values('ipmb_metabox_4');
foreach($values as $i => $value) {
echo "{$value['price']}";
}
?>
i wish to order the loop with price asc.
so far i have
query_posts(array(
'post_type' => 'used',
'paged' => $paged,
'posts_per_page' => 4,
'order' => 'ASC',
'orderby' => 'meta_value',
'meta_key' => 'price',
));
But this doesn’t work and i assume its because IP Metabox doesn’t register the Custom Post Meta like wordpress normally does with Custom Meta Fields. Could anyone advise please?
SOLVED:
query_posts(array(
'post_type' => 'used', // You can add a custom post type if you like
'paged' => $paged,
'posts_per_page' => 4,
'meta_key' => 'ipmb_metabox_4_price',
'orderby' => 'meta_value',
'order' => 'ASC',
));
Thank your to the Author of IP Metabox for the answer 🙂
it doesn’t works because your meta key was wrong. Since the metabox ID is
ipmb_metabox_4
and your field isprice
, the meta key should beipmb_metabox_4_price
. I’m sorry I didn’t write any documentation about this, because I don’t think people want to access to the meta key directly 🙂