Automatically Change WordPress Post Format With a Custom Field

My blogging workflow centers around MarsEdit, the fantastic blog editor by Daniel Jalkut. In my latest redesign of this site, I shifted to properly using Post Formats to define different post styles for my Link Posts versus Articles.

However, MarsEdit has one deficiency: there is no native support for setting Post Formats. I decided this was the time to take a stab at writing my first WordPress plugin, especially since writing Open Source code is one of my personal goals for 2014.

An hour of code later, I had a very simple plugin to solve this problem in MarsEdit. You can set a custom field to check, and a post format you’d like to change to.

Every time you create or update a post, it’ll check if you have a value set for that custom field. If you do, it’ll set the post format to your desired format.

The plugin is available on Github. It is currently in queue to be reviewed for the official WordPress plugin directory. If you come across any issues, feel free to open an Issue on Github, and Pull Requests are always appreciated!

Instructions

  1. Download the plugin to your wp-content/plugins directory.
  2. Open set-post-format.php, and set two variables: $custom_field is the name of the custom field that you want to trigger the format change, and $post_format is the post format you want to change to (e.g., “link” or “video”).
  3. Activate your plugin
January 7, 2014