Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
1  
Post types can be hierarchical - is this a question about url rewriting? –  Stephen Harris 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 Answer 1

up vote 1 down vote accepted

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);
share|improve this answer
    
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. –  Stephen Harris 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? –  Stephen Harris 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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