Hierarchical Pagelike Content Types

A hierarchical content type can have children, just as pages do. Listing 12-13 shows how to revise the plugin created in Listing 12-12 to make courses hierarchical.

Listing 12-13. Creating a non-hierarchical content type for courses

Plugin Name: Course Post Types

add_action('init', 'post_type_courses');

function post_type_courses() { register_post_type( 'course', array(

'rewrite' => true, 'query_var' => true, 'hierarchical' => true, 'supports' => array( 'title', 'editor', ' author' , 'excerpt', 'custom-fields', 'revisions', 'page-attributes',)

register_taxonomy_for_object_type('category', 'course');

Now your editing screen will look more like a page, as shown in Figure 12-16. And, since you now have the Attributes meta box, you can choose parents.

Edit Courts* * ifftni'rMf —

ÜI

1 1 ♦ |^tiilp:,/»QfiIpre5t/wP'*<irtn/iiettC»iîTpûM*>ï,»*&ltilcn«rclr

0 i-.pqpir

Word Press . simiEi^imu

ID" CIWli T fumlr. admin Tubv lUyOik |j

«

Edit Courses Shakespeare Syllabus

PufclKh

■a

Pre«» C'ji'jc!

Ui'cjd/lmcrt ® U £ •

iUfm mbhflEdiSl Viiull HTML vimilcy Pufall-tin

ID

i 1 ^ ^ LI

n PuHitfiti «1 Hi" 19. iOlQ CO tlx 7 Id t

(f

Vr.r tn Irnh

S

IL

Yeu can wiiAjr »our rjjh 1 cufpl*, wu coula ho* in ', tu» Mfe Vbry" and 'Ml Dm'

Yeu can wiiAjr »our rjjh 1 cufpl*, wu coula ho* in ', tu» Mfe Vbry" and 'Ml Dm'

niunn liynjn U wi

Figure 12-16. Editing the hierarchical content type with attributes meta box

Was this article helpful?

0 0

Post a comment