1

I already created a custom post type with post-format support declared.

register_post_type('portfolio', array(
        'labels' => array(
            'name' => __('Portfolio', "xxx"),
            'singular_name' => __('Portfolio', "xxx")
        ),
        'public' => true,
        'menu_position' => 5,
        'rewrite' => array('slug' => 'portfolio'),
        'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields', 'post-formats' )
            )
    );

However, when I go to Wordpress Export tool and try to export posts under this custom post type, I checked the exported xml file and saw that it doesn't export post-format value of posts.

Is there any solution for this?

2 Answers 2

1

After spending time debugging export.php, I found that we have to register post_format taxonomy for our custom post type.

register_taxonomy( 'post_format', 'portfolio', array(
            'public' => true,
            'hierarchical' => false,
            'labels' => array(
                    'name' => _x( 'Format', 'post format' ),
                    'singular_name' => _x( 'Format', 'post format' ),
            ),
            'query_var' => true,
            'rewrite' => $rewrite['post_format'],
            'show_ui' => false,
            '_builtin' => true,
            'show_in_nav_menus' => current_theme_supports( 'post-formats' ),
    ) );

Easy as that!

1
0

I was struggling with this as well. Your solution worked, until I found out that it will remove the post format taxonomy for normal post types!

After digging around the core files, I found this function which does exactly what we need:

register_taxonomy_for_object_type( 'post_format', 'portfolio' );

See Codex.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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