[Plugin: SortTable Post] Patch to allow specifying title for meta fields
-
[ Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still – use the pastebin ]
I really like the SortTable Post plugin! One of the reasons I chose this plugin was support for custom post types and meta properties. However, I was little sad that the slug for meta properties is displayed to the user as the column heading. So I modified the code to allow specifying meta=”field1|Title For Field 1,field2|Title For Field 2″. I find this a very useful feature and I suspect other users might too. Perhaps you’d consider adding the feature to the next release of the plugin? If so, see the patch below (patch is relative to version 4.2 of the plugin).
Thanks for a great plugin! Very handy!
Index: sorttablepost.php =================================================================== --- sorttablepost.php (revision 32) +++ sorttablepost.php (working copy) @@ -102,8 +102,14 @@ if( !$opt_notitles == 'true' ) { echo '<th>Title</th>'; } if( !$opt_nodates == 'true' ) { echo '<th>Date</th>'; } if( !$opt_excerpts == '' ) { echo '<th>' . $opt_excerpts . '</th>'; } - if( $opt_meta ) : foreach( $opt_meta as $key ) { - echo '<th>' . $key . '</th>'; + if( $opt_meta ) : foreach( $opt_meta as &$key ) { + list($field, $title) = explode('|', $key); + if (!empty($title)) { + echo '<th>' . sanitize_text_field($title) . '</th>'; + $key = $field; + } else { + echo '<th>' . $key . '</th>'; + } } endif; if( !$opt_nocats == 'true' ) { echo '<th>' . $catlabel . '</th>'; } if( !$opt_notags == 'true' ) { echo '<th>' . $taglabel . '</th>'; }
- The topic ‘[Plugin: SortTable Post] Patch to allow specifying title for meta fields’ is closed to new replies.