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

  1. mosheeshel
    Posted 3 years 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...


  2. Matthew Boynes
    Plugin Author

    Posted 3 years 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
    Posted 3 years 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
    Plugin Author

    Posted 3 years 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
    Posted 3 years ago #


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • SuperCPT
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.