0

How can I have post types shown on Page Attributes? For instance I have a custom post type which is product, and I want show it on Page Attributes alongside with the existing WP post types: page, post.

So I want so have a dropdown options and the user can switch around these post types:

post
page
product

My code in functions.php:

function product_init() {
    $args = array(
        'labels' => array(
            'name' => __('Products'),
            'singular_name' => __('Product'),
            'all_items' => 'All Products'
        ),
        'public' => true,
        'show_ui' => true,
        'capability_type' => 'page',
        'hierarchical' => true,
        // 'rewrite' => array('slug' => 'Products'),
        'query_var' => true,
        'menu_icon' => 'dashicons-star-filled',
        'supports' => array(
            'title',
            'editor',
            // 'excerpt',
            // 'trackbacks',
            //'custom-fields',
            //'comments',
            'revisions',
            'thumbnail',
            'author',
            'page-attributes',
            )
        );
    register_post_type( 'product', $args );
}
add_action( 'init', 'product_init' );

Any ideas?

  • so you need a drop down like Page Attributes -> Template for custom post type? – DHL17 Mar 12 '18 at 10:38
  • @DHL17 see my answer below. – laukok Mar 12 '18 at 10:42
0

A quick answer - post-type-switcher plugin below:

https://wordpress.org/plugins/post-type-switcher/

Though it would be great without a plugin.

  • 1
    There is nothing wrong with using a plugin for that. – swissspidy Mar 12 '18 at 10:55

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.