Best way to arrange custom post types by Attributes -> Order metabox value?

I have my front page setup to display a custom post type via:

add_filter( 'pre_get_posts', 'my_get_posts' );

function my_get_posts( $query ) {

    if ( is_home() && false == $query->query_vars['suppress_filters'] )         $query->set( 'post_type', array( 'jwf_portfolio', 'attachment' ) );
                $query->set( 'order', 'menu_order' );

    return $query; }

What’s the most efficient way to have these ordered by the number value in the Order input in the Attributes metabox for each custom post? Currently I’m trying

Read More
<?php query_posts( $query_string . '&orderby=menu_order' ); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

on my index.php and that’s not cutting it.

Related posts

Leave a Reply

1 comment

  1. This did it:

    add_filter( 'pre_get_posts', 'my_get_posts' );
    
    function my_get_posts( $query ) {
    
        if ( is_home() && false == $query->query_vars['suppress_filters'] )
            $query->set( 'post_type', array( 'jwf_portfolio', 'attachment' ) );
                    $query->set('orderby', 'menu_order');
                    $query->set('order', 'ASC'); 
    
        return $query;
    }
    

    No need to mess with index.php now.