WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Register Post Type, Attributes (14 posts)

  1. dorian06
    Member
    Posted 4 years ago #

    I have registered a Custom Post Type, named PRODUCTS, but now, I can't use the 'parent attribute' in this kind of posts, any ideas?

  2. MichaelH
    Member
    Posted 4 years ago #

    Use Pages instead.

  3. dorian06
    Member
    Posted 4 years ago #

    Ok, Thanks for reply.
    Sure I could use pages, but I would like to use custom post types, with different names and different custom fields, I'm almost there, because I see the attributes, but just the order attribute, must be a way to have parents in custom post type, or am i wrong?

  4. MichaelH
    Member
    Posted 4 years ago #

    must be a way to have parents in custom post type

    Set 'hierarchical' => true and make sure your supports include 'page-attributes'.

  5. dorian06
    Member
    Posted 4 years ago #

    Thanks Michael for taking the time! I'm really trying to make this work as expected, but with no luck so far.

    This is my function in functions.php
    note that, hierarchical is true, capability_type is PAGE and
    supports has page-attributes.

    function product_register() {  
    
            $args = array(
               'label' => __('Products'),
               'singular_label' => __('Product'),
               'public' => true,
               'show_ui' => true,
               'capability_type' => 'page',
               'hierarchical' => true,
               'menu_position' => 4,
               'rewrite' => true,
               'supports' => array('title','editor', 'thumbnail',  'page-attributes')
             );  
    
           register_post_type( 'product' , $args );
       }

    In the admin area I see Products like if the capability_type
    is POST (Bug maybe?) and, of course, I can't see Parent Attribute

    Anyway, this is how my wp-admin looks like:
    https://dl.dropbox.com/u/3610132/products.png

    Thanks for helping! appreciate :)

  6. MichaelH
    Member
    Posted 4 years ago #

    You won't see Parent until you publish at least one Product.

  7. dorian06
    Member
    Posted 4 years ago #

    OMG! Thx a lot, now its working great! :P

  8. MichaelH
    Member
    Posted 4 years ago #

    Note that I can't get "Template" to show in the Page Attributes module, but that's another subject.

  9. kathkeating
    Member
    Posted 4 years ago #

    did you ever figure out why you're not seeing "template" in the page_attributes module? I've got the same issue.

  10. madhavaji
    Member
    Posted 3 years ago #

    Are you sure you need the template dropdown?

    Templates apply to pages really. Your custom post type already has a template, it's called 'single-whateveryourcustompostiscalled.php'.

    Make sense?

    m.

  11. kathkeating
    Member
    Posted 3 years ago #

    yes, thanks I figured that out. I'm not using single-nnnnn.php for my custom post type templates.

    But I ended up having to implement the page-attributes support anyway because that's where the "order" field is. I think this is a "miss" on the custom post type feature set.

    People want to build custom post types because the capability of a "post" is insufficient. For example, I want to build an Art Portfolio. An Art Portfolio needs to have sorting capability - it should not be sorted by date. Custom post types appear to be completely restricted to to behaving like "posts" not "pages" when it comes to these basic features.

    A significant amount of work needs to be done to jury-rig the custom post types to have page-like qualities. For example, I can now set the "order" field because I added "page-attribute" support, but I can't get "order" to appear in the Custom Post Type list. And I can't get the Custom Post Type list to be sorted by "order" when it's displayed. All of these very simple things seem to be very complicated to override.

    But I'm still digging for answers!

  12. bmil21
    Member
    Posted 3 years ago #

    Is there a way to set a custom post type's parent as a static page that has already been created. Maybe have some sort of code that enables the regular static page 'Parents' to show up as they do in the pages admin section.

    If further explaining is needed, feel free to ask.

    Thanks for any help.

  13. noname.olsson
    Member
    Posted 3 years ago #

    @bmil21 Did you figure out how to do that? I also have to do that.

  14. kjmeath
    Member
    Posted 3 years ago #

    When you create a custom post type, is it possible to get the "Template" feature to show in the Page Attributes module?

    Someone link me to some info on whats up with this.

    Cheers!

Topic Closed

This topic has been closed to new replies.

About this Topic