WordPress.org

Ready to get started?Download WordPress

Plugin Directory

!This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Boone's Sortable Columns

A handy, extensible class for adding sortable columns your custom post type lists.

Here's how I recommend using the class.

  1. Either activate this plugin, or include the class in your own plugin file.
  2. When you start to render the page with the post list, define some columns and then instantiate 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 );
  1. As you render your table, you can use all sorts of fun methods to create column headers. Example:
<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: 539

Ratings

5 stars
5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1