0

I want create "Custom Post Type" that will have next structure:

Post (hierarhy level)-(some-post-id)

Post 1-1 =>

      Post 2-2
      Post 2-3
      Post 2-4 =>
               Post 3-5
               Post 3-6
               Post 3-7
      Post 2-8
      Post 2-9
      Post 2-10

I need something like "Page attributes":

http://s019.radikal.ru/i638/1205/19/d533f543c5f7.png

2
  • 1
    Post types can be hierarchical - is this a question about url rewriting? May 10 '12 at 8:17
  • I want have custom posts type, like standart page, that have hierarhy level
    – Vital
    May 10 '12 at 9:26
1

You can set a post type to hierarchical when you register it with register_post_type. Simply set the 'hierarchical' argument to true.

  $args = array(
    'public' => true,
    'publicly_queryable' => true,
    'has_archive' => true, 
    'rewrite' => true,
     ...
    'hierarchical' => true,
     ...
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments','page-attributes' )
  ); 
  register_post_type('my-cpt',$args);
7
  • Once more, We must add into support, 'page-attributes' But still no results, because there will be only "order" option. I want have hierarhy like by pages, where I will can specify level (parent, grandchild, child and so on).
    – Vital
    May 10 '12 at 10:30
  • Indeed, I'd left out the 'supports' argument. May 10 '12 at 10:32
  • But still no results ;)
    – Vital
    May 10 '12 at 10:36
  • In what sense no results? - this works for me (without the '...'s of course.) Does the post type not register, or are you not seeing the page attributes metabox? May 10 '12 at 10:37
  • I see s019.radikal.ru/i612/1205/ca/ca78b6f561e7.png
    – Vital
    May 10 '12 at 10:40

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.