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:
Single & Not Looking
Joined: 01/14/2009
Posts: 2626
Drops: 3113
Mood: Energetic

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

kaden's picture
budibanyu's picture
Sadjuice's picture
Mouahd rjeb's picture
nigelbdhmp's picture
Valo's picture
beferry's picture
Mr.Bullet44's picture
XaicOaken's picture
Mike49's picture
Diablo4gold's picture
ZeonLau1's picture
ZeonLau12's picture
ZeonLau's picture
Oruwariye's picture
facebook codes exploits tips tricks Phrozen Crew
All contents ©Copyright GeekDrop™ 2009-2025
TOS | Privacy Policy