Custom post order by page-attributes

1.  add page-attributes uner ‘supports’

function prefix_register_name() {

 $labels = array(
 'name' => __( 'Plural Name', 'text-domain' ),
 'singular_name' => __( 'Singular Name', 'text-domain' ),
 'add_new' => _x( 'Add New Singular Name', 'text-domain', 'text-domain' ),
 'add_new_item' => __( 'Add New Singular Name', 'text-domain' ),
 'edit_item' => __( 'Edit Singular Name', 'text-domain' ),
 'new_item' => __( 'New Singular Name', 'text-domain' ),
 'view_item' => __( 'View Singular Name', 'text-domain' ),
 'search_items' => __( 'Search Plural Name', 'text-domain' ),
 'not_found' => __( 'No Plural Name found', 'text-domain' ),
 'not_found_in_trash' => __( 'No Plural Name found in Trash', 'text-domain' ),
 'parent_item_colon' => __( 'Parent Singular Name:', 'text-domain' ),
 'menu_name' => __( 'Plural Name', 'text-domain' ),
 );

 $args = array(
 'labels' => $labels,
 'hierarchical' => false,
 'description' => 'description',
 'taxonomies' => array(),
 'public' => true,
 'show_ui' => true,
 'show_in_menu' => true,
 'show_in_admin_bar' => true,
 'menu_position' => null,
 'menu_icon' => null,
 'show_in_nav_menus' => true,
 'publicly_queryable' => true,
 'exclude_from_search' => false,
 'has_archive' => true,
 'query_var' => true,
 'can_export' => true,
 'rewrite' => true,
 'capability_type' => 'post',
 'supports' => array(
 'title', 'editor', 'author', 'thumbnail',
 'excerpt','custom-fields', 'trackbacks', 'comments',
 'revisions', 'page-attributes', 'post-formats'
 )
 );

 register_post_type( 'slug', $args );
}

add_action( 'init', 'prefix_register_name' );

2. Query post add ‘orderby’=>’menu_order’ and ‘order’=>’ASC’

query_posts( array('orderby'=>'menu_order','order'=>'ASC' ) );

Done!


Leave a Reply