I’m using post formats heavily on a project, but have no current need for the standard option. Beyond being an unnecessary bit of UI, it actually causes broken behavior if it does get mistakenly selected. I might, with some convoluted logic, be able to set up a template for Standard that properly handles the incoming content of other formats, but all that would really do is hide the fact the posts are assigned incorrectly, making them even harder to hunt down. (And this workaround may or may not always be viable.) The real problem is that the radio button just shouldn’t be there.
The only option I’ve seen for removing format support in any way is remove_theme_support('post-formats')
which kills the feature altogether. I just want that one option gone.
The first thing to remember about the post editing screen is that everything (except for the post title, editors, permalink, etc.) is a meta box. Since you can easily add and remove meta boxes, there’s no need for CSS and JS hacking. Don’t want the standard post format to show up? Remove the default meta box and roll your own.
First hook into
add_meta_boxes_{$post_type}
and remove the old format div, and add your own.You can find the code for the default post format meta box in
wp-admin/includes/meta-boxes.php
inside the functionpost_format_meta_box
. Here it is:The easiest thing to do is to copy the entire deal, rename the function and change the stuff we need to change. Name, that means changing this:
To the following to set the “default format” to aside (or whatever you want it to be).
We’ll also need to remove this line:
Which is the “standard” post format. The final result:
Finally, it would be a good idea to make sure
get_post_format
never returns false, or, rather, also returns your default format in the absence of a format. Post formats are just a taxonomy, so we can hook intoget_the_terms
and make sure we always have a post format. Formats are created as posts are added to them, so we have to add the taxonomy if it doens’t exist already.Here is all that as a plugin.
Based on your comment:
I think the most correct approach is for you not to use the Post Format taxonomy at all; rather, you should be using your own custom taxonomy. You’re not using the Post Format taxonomy as it is intended to be used, and it doesn’t serve your purposes; so, why try to force a square peg into a round hole?
Just register your own taxonomy (heck, even copy the useful bits from the post format taxonomy registration code), and omit “standard” term/handling altogether.
This is a semi-hacky workaround, but I think it meets all your needs. First, implement the template logic to handle the case where for some reason you do have a post that is set as the “Standard” post format.
Next, create a simple plugin that will add custom CSS and JS in your admin interface. Create a “myplugin” directory under /wp-content/plugins and place this code in “myplugin.php”:
Next, also in the /myplugin/ folder, create the above referenced wp-admin.css and wp-admin.js files.
In wp-admin.css put styles to remove the “Standard” option from being seen by your Authors:
Finally, in wp-admin.js place a line of JavaScript that will select the post format that you want the users to use by default.
The caveat of this approach is that this isn’t actually removing the Standard post format in WP, but simply hiding it from your Authors using JavaScript and CSS. If the Author doesn’t have JS enabled in their browser, the “Standard” post will still be the default selected. I believe this is still the best and only solution to this issue though.
Good luck!
Ist not enough you add the post format and filter via the array of allowed post formats? maybe i dont understand the question not right.
in functions.php of the Theme; allowed post format for Aside and Image.
add_theme_support( 'post-formats', array( 'aside', 'image' ) );