A handy, extensible class for adding sortable columns your custom post type lists.
Here's how I recommend using the class.
$cols = array(
array(
'name' => 'restaurant_name',
'title' => 'Restaurant Name',
'css_class' => 'restaurant-name',
'is_default' => true
),
array(
'name' => 'cuisine_type',
'title' => 'Cuisine Type',
'css_class' => 'cuisine-type',
'default_order' => 'desc'
)
);
$sortable = new BBG_CPT_Sort( $cols );
<table class="widefat">
<thead>
<?php if ( $sortable->have_columns() ) : ?>
<?php while ( $sortable->have_columns() ) : $sortable->the_column() ?>
<th class="<?php $sortable->the_column_css_class() ?>">
<a href="<?php $sortable->the_column_next_link( 'url' ) ?>"><?php $sortable->the_column_title() ?></a>
</th>
<?php endwhile ?>
<?php endif ?>
</thead>
<tbody>
...
</tbody>
</table>
Requires: WordPress 3.1 or higher
Compatible up to: WordPress 3.2-beta
Last Updated: 2011-5-21
Downloads: 257
Got something to say? Need help?