0

I added post-formats support like below.

add_theme_support( 'post-formats', array( 'gallery', 'link', 'quote', 'audio', 'video' ) );

I also added post-formats support to custom post type like below.

add_post_type_support( 'my-custom-post-type', 'post-formats' );

My question is: Is it possible to use different post formats on regular posts and custom post type?

For example, using 'gallery', 'link', 'quote', 'audio', 'video' on regular posts, and only 'gallery', 'video' on custom post type.

1

This should get you going in the right direction. Not my solution, slightly modified from here.

You'll need to swap out your-post-type for the post type you're using.

function adjust_post_formats() {
    if (isset($_GET['post'])) {
        $post = get_post($_GET['post']);
        if ($post)
            $post_type = $post->post_type;
    } elseif ( !isset($_GET['post_type']) )
        $post_type = 'post';
    elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) )
        $post_type = $_GET['post_type'];
    else
        return;

    if ( 'your-post-type' == $post_type )
        add_theme_support( 'post-formats', array( 'gallery' ) );
    elseif ( 'post' == $post_type )
        add_theme_support( 'post-formats', array( 'gallery', 'link', 'quote', 'audio', 'video' ) );
}
add_action( 'load-post.php','adjust_post_formats' );
add_action( 'load-post-new.php','adjust_post_formats' );
  • Thanks @corygibbons, it works pretty well except one little thing. The fix is here – Sodbileg Gansukh Jul 25 '14 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.