User Login

Help Community Login:

How To Customize the Column Orders in WordPress [Code Example]

STaRDoGG's picture
From:
Olympus
STaRDoGG
Head Mucky MuckJoined the Dark SidePremium Member (Gold)I'm a Code Monkey!The Steel CurtainI use FirefoxI use Google ChromeI use Internet ExplorerI use SafariLinux UserMac UserWindows UserI donated to GeekDrop simply because I love it!Booga Booga BoogaI took a bite of the AppleFormer Phrozen Crew MemberI'm MagicMember of VileThe Dr. put the stem on the apple!The JokerSomeone thinks you're udderly delightful!
Relationship Status:
Divorced
Joined: 01/14/2009
Posts: 2556
Drops: 3007
Mood: Curious

While working on one of my WordPress sites I stumbled upon the need to customize (reorder) the column order while I was adding new columns on some admin pages. Specifically in my case, the "Manage Posts" and "Manage Pages" pages. I saw people on the coding sites asking how to do it, with no one responding to them, and I was unable to really come up with a simple example by doing a little Google-Fu, so I figured it out on my own and thought I'd share.

All you really need to do is shuffle around the $defaults variable (which is an array). Here's the code:

 
global $defaults;
 
$defaults['cb'] = '<input type="checkbox" />';
$defaults['thumbnail'] = __('Thumbnail');
$defaults['title'] = __('Title');
$defaults['author'] = __('Author');
$defaults['categories'] = __('Categories');
$defaults['tags'] = __('Tags');
$defaults['comments'] = '<span class="vers"><span class="comment-grey-bubble" title="Comments"></span></span>';
$defaults['date'] = __('Date');
$defaults['hits'] = __('Hits');
$defaults['wherego'] = __('Where Go');
 
return $defaults;
 

And that's it.

This particular code is what I created for the Manage Posts/Pages editor, when I added image thumbnails to them.

If you're already at this point you're most likely adept enough at understanding PHP and exactly what the above code is doing, so no need for a full explanation.

One tip though: You can play around all you want with it and if you want the columns to go back to the default locations you can simply comment out the "global $defaults;" line, and the normal columns will be in their original places. If you added any custom columns they'll fall into place near the end.

I Averaged: 4 | 1 vote


Read More ...





Who's New

paeltc's picture
dimpy123's picture
dfuller4747's picture
Bob the Observer's picture
Skalski5's picture
quattro2468's picture
davidclay123's picture
Sunny's picture
ZDooX's picture
Miamihot2007's picture
Fred McBen's picture
Sri's picture
bammer's picture
akay's picture
r1sc's picture
facebook codes exploits tips tricks Phrozen Crew
All contents ©Copyright GeekDrop 2009-2017
TOS | Privacy Policy