WordPress.org

Ready to get started?Download WordPress

Forums

Custom Meta boxes for Custom Post Type in 3.0? (4 posts)

  1. heavym
    Member
    Posted 3 years ago #

    Hello All,

    I hope their are others out there as pumped about the power of Custom Post Types and Custom Meta Boxes in WordPress 3.0 as I am. As I'm new to the area I imagine others have figured out more than I.

    In my functions.php file I successfully created a new custom post type called "feature".

    /*Add Feature Custom Post Type*/
    register_post_type('feature', array(
    'label' => __('Featured'),
    'singular_label' => __('Feature'),
    'public' => true,
    'show_ui' => true, // UI in admin panel
    '_builtin' => false, // It's a custom post type, not built in!
    '_edit_link' => 'post.php?post=%d',
    'capability_type' => 'post',
    'hierarchical' => false,
    'rewrite' => array("slug" => "featured"), // Permalinks format
    'supports' => array('title','page-attributes','custom-fields','editor','thumbnail','excerpt')
    ));

    In the admin panel for that new custom post type I need to add a few new meta boxes that will only show up their.

    These will be:

    • Subtitle: a single text field with title and description.
    • URL: a single text field with title and description.
    • Quote: a text box with title and description. (the size of Excerpt)
    • Feature: a single checkbox with title and description.
    • Bullets: a text box with title and description. and each line is is put into a list element

    Then I would need the variables for each of those boxes or a way to show each in a template for featured posts.

    This post does pretty much exactly what I need but is not written for WordPress 3.0 and Custom Post Types also its a plugin and I would like to build it into my functions file.
    http://www.wordpressurls.com/example-how-to-add-meta-boxes-to-edit-area/

    Any advice on how to do this, whether articles to look at, or code examples on how to modify the code in the link above, I would be so grateful! I know the plugin, "More Fields" will eventually be available for WP 3.0 but it currently is not, and trying to do this sooner than later. The makers of More Fiends did release More Types which is for 3.0 but that simply creates the Custom Post Type, which I did with code in a few minutes.

    Thank you in advance!

    Cheers,
    Christopher

  2. heavym
    Member
    Posted 3 years ago #

    Also, the content from the original article above is actually from WPEngineer (as noted on that site): http://wpengineer.com/example-how-to-add-meta-boxes-to-edit-area

    And I have been able to add the plugin code to my functions.php file. My main hurtle is needing to know how to apply all that to just one new custom post type rather than the default post type which is does currently.

    The other question would be how to create a text box option in the meta boxes as well in the code above. Thank you!

    Cheers,
    Christopher

  3. Matt Hill
    Member
    Posted 3 years ago #

    I haven't read this article in detail, but I think it teaches you what you need:

    http://blog.genuineinteractive.com/post/adding-custom-field-gui-to-custom-post-types-wordpress-3.aspx

  4. thewebsolutionprovider
    Member
    Posted 3 years ago #

    here is how to create meta boxes in a plugin page rather than post/page edit screens: http://thewebsolutionprovider.com/wordpress/wordpress-tutorials/custom-wordpress-meta-box-for-your-plugins/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags