WordPress: add page-attributes support to custom post type

By using add_post_type_support we can enable some things in an already registered custom post type that may not already be enabled. In this example we make an add_action hook where we enable page-attributes so that we can see the meta-box page-attributes in wp-admin for the post type "product".

/* Post type support changes */
add_action( 'admin_init', 'products_attributes');
function products_attributes(){add_post_type_support( 'product', 'page-attributes' );}
    The function accepts the following string values:

  • 'title'
  • 'editor' (content)
  • 'author' (author)
  • 'thumbnail' (the current theme must also support Post Thumbnails)
  • 'excerpt'
  • trackbacks
  • 'custom-fields' (see Custom_Fields, also known as meta-data)
  • 'comments' (will also see a balloon with comment count on the edit screen)
  • 'revisions' (will save revisions)
  • 'page-attributes' (template and menu order) (hierarchical must be true)
  • 'post-formats' (see Post_Formats)

  • Please note that in the 'thumbnail' value you can also use 'attachment:audio' and 'attachment:video' .