arcath / post-formats
Post Format meta boxes for WordPress
Requires
- php: ^5.3.3 || ^7.0
This package is auto-updated.
Last update: 2024-11-08 07:19:15 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.