arcath/post-formats

Post Format meta boxes for WordPress

0.0.4 2018-01-25 13:15 UTC

This package is auto-updated.

Last update: 2024-04-08 06:10:00 UTC


README

Provides meta boxes and all required code to get the WordPress post formats working in the admin panel.

Does not provide any helpers for displaying in your theme.

Install

You can install through composer using the command:

composer require arcath/post-formats

Usage

Requiring composer autoload will add the PostFormats class.

functions.php

require_once('vendor/autoload.php');

$formats = array('gallery', 'video');
asort($formats);
$post_formats = new PostFormats($formats, array('post', 'page'));

new PostFormats takes 2 arguments, an arry of formats to enable (which I have sorted alphabetically above) and an array of post types to enable them for.

In your theme

The contents of the meta box is stored in _post_format_{POST_FORMAT} in the post meta.

For example to get the array of gallery IDs you would look at _post_format_gallery.

More info can be found in this post.