WordPress.org

Ready to get started?Download WordPress

Forums

Wrong order for get_posts using custom type (7 posts)

  1. TinkerWorkshop
    Member
    Posted 3 years 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.

  2. DigitalSquid
    Member
    Posted 3 years ago #

    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."

  3. TinkerWorkshop
    Member
    Posted 3 years ago #

    Thanks for the reply, mate.

    Yes, I have a custom post type, inheriting from Page.

  4. Paolo
    Member
    Posted 3 years ago #

    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.

  5. TinkerWorkshop
    Member
    Posted 3 years ago #

    Paolo,
    No, I am all vanila set up.

  6. teknohippy
    Member
    Posted 3 years 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) {
  7. teknohippy
    Member
    Posted 3 years ago #

    My problem was a type, should be "orderby" of course.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags