1

I am creating a custom calendar plugin but I am stumped with the connection of post types.

I have a 2 post types "Calendars" and "Events". I would like to create a metabox that contains a table just like the post type page along with the add post button to add a new event.

I have created the metabox using the following.

add_action( 'admin_init', 'add_meta_boxes' );
function add_meta_boxes() {
    add_meta_box( 'events_metabox', 'Events', 'display_events', 
     'plugin_calendar', 'normal' );
}

function display_events(){

    // Display table and add button.

}

I am also using ACF Pro to add fields to each post type if this makes it easier to do what I am trying to accomplish.

0

I am doing something very similar, also with Advanced Custom Fields. My project has 2 custom post types; Programs and Exercises. Like your Calendar and Events cpt, I have multiple Exercises linked to each Program. The way I do it is with Post Objects. I add Exercises as field type Post Object, filtered by post type, to the ACF Field Group. No meta boxes needed.

  • 1
    This wont work. The Plan is to put a post type within a post type. By doing what you are it makes it harder on the customer. We deal with a lot of people that do not work well with computers. I was able to display the entire table on the page but now I have to figure out how to move it outside the form tag. – James Jan 22 '17 at 3:17
  • Are you using a child theme and cpt-template file to display your calendar post? Can you share a link to your current page view? – David Cook Jan 22 '17 at 3:33
  • This is being developed as a plugin with a shortcode. I dont have enough room here to explain how the system is working. – James Jan 22 '17 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.