User Login

Help Community Login:

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

STaRDoGG's picture
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: 2563
Drops: 3020
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

bebiiee's picture
JustLOVETheGeek's picture
jhonzeth's picture
kaushalmalkan11's picture
avinash.5107218's picture
Raez's picture
MondayTuesday09's picture
sabrina_marie's picture
Tallen's picture
aaron420's picture
Viktor123's picture
paeltc's picture
dimpy123's picture
dfuller4747's picture
Bob the Observer's picture
facebook codes exploits tips tricks Phrozen Crew
All contents ©Copyright GeekDrop 2009-2017
TOS | Privacy Policy