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: 2611
Drops: 3094
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

Anonymous_Hacker's picture
rogerwinhye's picture
nemesis3290's picture
chap2315's picture
Pancake's picture
Stephenhaw909's picture
travis's picture
hawkeyefxr's picture
Michaelchung2002.'s picture
Norielm19's picture
vankemp68's picture
ajfan91's picture
Circuit VPN's picture
itsjusme's picture
Wcochran271's picture
facebook codes exploits tips tricks Phrozen Crew
All contents ©Copyright GeekDrop™ 2009-2022
TOS | Privacy Policy