I want to add post formats for each post type. For example, I have a post type ‘Gallery’. I want to add ‘images’, ‘galleries’ and ‘videos’ in this post. In normal posts I want to use another list of post formats.

I try:

function postf()
{
    global $post_ID;

    $postType = get_post_type( $post_ID );

    if( $_GET['post_type'] || $postType == 'gallery-custompost' )
    {
        add_theme_support( 'post-formats', array( 'image', 'gallery', 'video' ) );
        add_post_type_support( 'gallery-custompost', 'post-formats' );
    }
}
add_action('init', 'postf');

When I add a new post, it works, but when I try to edit it, the post format does not appear.

Does anyone have any idea how I must do it?

3 Answers
3

Try adding the post format support on the arguments when you register your post type instead of using add_post_type_support, like this for example:

$args = array(
    ...
    'supports' => array('title', 'editor', 'author', 'post-formats')
); 
register_post_type('gallery-custompost', $args);

See if have any luck.

Leave a Reply

Your email address will not be published. Required fields are marked *