WordPress.org

Ready to get started?Download WordPress

Forums

SuperCPT
[resolved] Adding a Meta Box to an Existing Post Type (5 posts)

  1. mosheeshel
    Member
    Posted 1 year ago #

    How do I add a Meta Box to regular post or page (when I try using:
    $posts = new Super_Custom_Post_Type( 'post' );)
    It creates an Additional content type named posts...
    And the functionality is duplicated...

    http://wordpress.org/extend/plugins/super-cpt/

  2. Matthew Boynes
    Member
    Plugin Author

    Posted 1 year ago #

    Correct, you do not want to declare a new Super_Custom_Post_Type for psots or pages. Instead, you'll want to instantiate Super_Custom_Post_Meta and pass it 'post' or 'page', then you can call add_meta_box on that object. Something along the lines of:

    $post_meta = new Super_Custom_Post_Meta( 'post' );
    $post_meta->add_meta_box( ... );

    For future reference, you can find all the documentation here, which covers doing this.

  3. mosheeshel
    Member
    Posted 1 year ago #

    Hi Matthew,

    Thanks for the support!
    This works, however, when I use this functionality the connect_types_and_taxes function does not work to connect custom taxonomies to this post type
    -----------------
    Call to undefined method Super_Custom_Post_Meta::connect_taxes

  4. Matthew Boynes
    Member
    Plugin Author

    Posted 1 year ago #

    That is correct. As mentioned in the docs, you can only pass Super_Custom_Post_Type and Super_Custom_Taxonomy objects through connect_types_and_taxes.

    To connect a custom taxonomy to an existing post type, call the method connect_post_types on the Super_Custom_Taxonomy object and pass it the post type. For instance,

    $authors = new Super_Custom_Taxonomy( 'author' );
    $authors->connect_post_types( 'post' );
  5. mosheeshel
    Member
    Posted 1 year ago #

    Great!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.