How To Add Universal Theme Support For WordPress Post Formats Using A Plugin

Anyone who uses WordPress regularly knows about the Post Format feature and while it is great, the problem with it is that it is tied to the template you are using. And a lot of theme developers pick and choose which formats they support and some just straight up don’t support them. Now while it isn’t a problem if you have never used them, if you do use them, you tend to lose support for some formats when you change themes. Which is why after much contempt, I decided that I would just write a plugin to handle it.

So here’s how you can do just that.

Firstly open up your favorite text editor and create a new .php file

Open the new file you just created and add the following

<?php

?>

Those lines signal the beginning and end of the file, it is important that you have nothing and I mean NOTHING after the last line.

Next up we need to add the headers for the plugin so that we can be able to identify it and activate it in WordPress, you can just copy what I have and change my information for yours.

/**
 * Plugin Name: Post Format Support
 * Description: A simple plugin that overrides the default post format support of themes, without the need to edit the theme's files.
 * Version: 1.0.0
 * Author: Delano Maloney
 * Author URI: https://delanomaloney.com/
 * License: GPL3
 */

If you save and add the plugin to your site you should see it show up as a valid plugin, with version number and everything, don’t activate it just yet, as the plugin does do anything yet.

Now for the final step, below the plugin headers add the following lines of code

function ddm_add_post_formats() {
    add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) );
    }

add_action( 'after_setup_theme', 'ddm_add_post_formats', 20 );

Those lines adds the complete list of post formats to the WordPress editor, so that you can select them when writing up the post, it is important to remember that if your theme doesn’t support post formats you wont see a change on the frontend of your site, but you will have the options in the editor.

Just a quick recap so you know what the file should look like at the end

<?php 
/**
 * Plugin Name: Post Format Support
 * Description: A simple plugin that overrides the default post format support of themes, without the need to edit the theme's files.
 * Version: 1.0.0
 * Author: Delano Maloney
 * Author URI: https://delanomaloney.com/
 * License: GPL3
 */

function ddm_add_post_formats() {
    add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) );
    }

add_action( 'after_setup_theme', 'ddm_add_post_formats', 20 );

?>

If you are feeling lazy and don’t want to go through all of this, I did make it into an actual plugin that you can download here (DDM Post Format Support)

Advertisements