I'm looking for a way to set the default "View" options under post types in the admin area. For example, by default Posts will default to a "list" view instead of "excerpt" - I'd like to change this to excerpt by default - what would be the best way to achieve this? I've done a bit of searching on this, but am stuck in the mud thus-far. Any help would be greatly appreciated. Thanks!
Although having the feature of persistent settings in core is nice, it may take quite a while before it's actually accepted. WordPress 3.5 is still quite far away.
So let's augment the global
This will lock up modes, forcing
You can further interpolate
Viola! Persistent list mode per post type per user, no hacks.
The post view screen switches from list view to excerpt view based on the value of the "mode" parameter in the query string. If the "mode" parameter is not set, then WordPress defaults to list view.
Unfortunately, this parameter is not filterable, so there's no easy way to control it programatically.
So I'm going to do something I never do ... I'm going to tell you how to hack Core to make this work ...
Adding a filter
On line 99, WordPress checks to see whether or not the "mode" parameter was set in the request and uses this to set the global
We're going to change this line to filter the default setting. Change this line to:
Now, go into your theme's
This will hook in to the filter and return excerpt mode by default.
Since my personal rule about hacking Core requires that all hacks be contributed back to the project (this way they can be rolled into Core and no longer count as a hack), I've opened a Trac ticket for this enhancement and submitted the code above as a patch. Please weigh in on the ticket so that it can get into core for 3.5 (we're too late in the cycle for 3.4, but we can try to push this through for the next version).
Okay, so shortly after I put a bounty up, I came up with the following solution. It is the default behaviour in every way, except that it selects excerpt view for whatever post type you want (instead of the default list view).
NOTE: I recommend Soulseekah's approach, if you don't want it to remember the user's choice, you can incorporate my code with his code a bit. NOTE 2: If/when EAMann's patch is part of the core, obviously his method would be the best one as it wouldn't require you to go the long way round. I just don't like it at the moment as you have to edit the core files.