Hi @joelschmid,
Let me know if this is the correct situation you have:
1. You have the crb_ws-id
field added to all posts
2. You wish to pull all posts and order them based on the value they have in their crb_ws-id
field
To achieve the above use this:
`
$args = array(
‘posts_per_page’ => 5,
‘offset’ => 0,
‘category’ => $settings->tax_post_category,
‘meta_key’ => ‘_crb_ws-id’, // NOTE: don’t forget the leading underscore – meta keys are stored with an underscore prepended to the field name
‘orderby’ => ‘meta_value_num’, // NOTE: change to ‘meta_value’ if the values in crb_ws-id are not numeric
‘order’ => ‘DESC’,
);
$myposts = get_posts( $args );
`
Hi @joelschmid,
Let me know if this is the correct situation you have:
1. You have the crb_ws-id
field added to all posts
2. You wish to pull all posts and order them based on the value they have in their crb_ws-id
field
To achieve the above use this:
$args = array(
'posts_per_page' => 5,
'offset' => 0,
'category' => $settings->tax_post_category,
'meta_key' => '_crb_ws-id', // NOTE: don't forget the leading underscore - meta keys are stored with an underscore prepended to the field name
'orderby' => 'meta_value_num', // NOTE: change to 'meta_value' if the values in crb_ws-id are not numeric
'order' => 'DESC',
);
$myposts = get_posts( $args );