TinkerWorkshop
Member
Posted 1 year ago #
$args = array('post_type'=>'myType','numberposts'=>-1,'meta_key'=>'featured','meta_value'=>'true','orderby'=>'menu_order','order'=>'ASC');
foreach(get_posts($args) as $item){}
While using this code my "orderby" parameter has no effect.
I've tried looking around the forums but can't see anything exactly the same: some things here and there are similar, but nothing precisely the same.
Thanks for the assistance.
I don't think posts have a 'menu order' to be organised by.
Looking at the Codex page for the menu_order parameter:
http://codex.wordpress.org/Template_Tags/get_posts#Parameters:_WordPress_2.5_And_Older
It says that menu_order is "Only useful with pages and attachments."
TinkerWorkshop
Member
Posted 1 year ago #
Thanks for the reply, mate.
Yes, I have a custom post type, inheriting from Page.
Hi,
Are you by any chance using a plugin like Post Type Order to order your posts by drag and drop?
If yes, check its settings, it has a "auto-order" option that overrides your orderby parameter in the queries, just uncheck it and you're done.
TinkerWorkshop
Member
Posted 1 year ago #
Paolo,
No, I am all vanila set up.
teknohippy
Member
Posted 1 year ago #
Similar problem here with a custom post type.
$args = array(
'post_type' => 'cyclepanel',
'numberposts' => -1,
'category_name' => get_post_meta( $post->ID, 'CyclepanelCategory', true),
'order_by' => 'menu_order',
'order' => 'ASC'
);
$cyclepanels = get_posts($args);
if ($cyclepanels) {
foreach ($cyclepanels as $cyclepanel) {
teknohippy
Member
Posted 1 year ago #
My problem was a type, should be "orderby" of course.