Introducing Post Format Block

Post Formats are a somewhat neglected feature in WordPress. How neglected? Well as I discovered, there isn’t a block for it in Full Site Editing So I decided to build it and thankfully it is super easy. The @wordpress/create-block package got the majority of my scaffold for me in minutes, after that it just a little bit of JavaScript and a little bit of PHP to power my new plugin.

// Block Registration Function
import { registerBlockVariation } from '@wordpress/blocks';

// Internationalization
import { __ } from '@wordpress/i18n';

// Icon
import { postCategories as icon } from '@wordpress/icons';

const variation = {
        name: 'post_format',
        title: __('Post Format'),
        description: __("Display a post's format"),
        isDefault: true,
        attributes: { term: 'post_format' },
        isActive: (blockAttributes) => blockAttributes.term === 'post_format',

registerBlockVariation( 'core/post-terms', variation );

Block Variations make it so that I don’t need to build a block from scratch, and the core/post-terms block is already designed for this. The Post Tags and Category blocks are both variations on the post terms block.

On the server side, I just needed to register my block and make sure that post formats are always available for the Rest API.

 * Register our block
 * The block type we register is actually a variant, but this allows it to show up as a "block" plugin.
function jorbin_post_format_block_block_init() {
        register_block_type( __DIR__ );

add_action( 'init', 'jorbin_post_format_block_block_init' );

 * Make the post formats avilable in the REST API
function jorbin_post_format_block_taxonomy_args( $args, $taxonomy_name ) {
    if ( 'post_format' === $taxonomy_name ) {
        $args['show_in_rest'] = true;
        return $args;
add_filter( 'register_taxonomy_args', 'jorbin_post_format_block_taxonomy_args', 10, 2 );

This is my first new plugin since BRAD and my first ever block-based plugin. If you also love Post Formats, give it a try!

You can download the plugin from the WordPress Plugin Repository. Additionally, pull requests and bug reports are welcome to, but I will likely consider this complete software and don’t intend to add any new features.



  1. This Article was mentioned on

  2. […] 讘诇讜拽 post format, 讜住拽讬专讛 砖诇 讝讛 讘-WPTavern – 讗讞讚 诪诪驻转讞讬 讜讜专讚驻专住 讛诪讜讘讬诇讬诐, Aaron Jorbin, 讛讞诇讬讟 砖讗讬谉 诪住驻讬拽 讛转讬讬讞住讜转 诇-post formats 讜诇讻谉 驻讬转讞 讘诇讜拽 讻讝讛. 讜砖专讛 讙讜讚讬谞讚 诪–WPTavern 住拽专讛 讗讜转讜. […]

%d bloggers like this: