post_conn_array = $post_types; !is_array($post_types)?($post_types = array()):''; //limit meta box to certain post types $add_meta_box = 0; foreach($post_types as $post_conn_name => $type){ if( isset($type['connected_by']) and $type['connected_by'] == $post_type ){ $this->connected_post_types = $type['connected_posts']; !is_array($this->connected_post_types)?($this->connected_post_types = array()):''; $add_meta_box = 1; break; } //to add meta box to connected post as well foreach($type['connected_posts'] as $each_post_type){ if($each_post_type == $post_type){ array_push($this->connected_by,$type['connected_by']); add_meta_box( $post_conn_name ,__( 'Set Connections' ) ,array( $this, 'render_meta_box_content' ) ,$each_post_type ,'advanced' ,'high' ); } } } if($add_meta_box == 0) return; //if ( in_array( $post_type, $post_types )) { add_meta_box( 'flex_post_connection' ,__( 'Set Connections' ) ,array( $this, 'render_meta_box_content' ) ,$post_type ,'advanced' ,'high' ); //} } /** * Render Meta Box content. * * @param WP_Post $post The post object. */ public function render_meta_box_content( $post ) { // Add an nonce field so we can check for it later. wp_nonce_field( 'myplugin_inner_custom_box', 'myplugin_inner_custom_box_nonce' ); // Use get_post_meta to retrieve an existing value from the database. $connected_posts = get_post_meta( $post->ID, 'flex_connected_posts', true ); !is_array($connected_posts)?($connected_posts = array()):''; // Display the form, using the current value. ?>
'.get_the_title().'
'; endwhile; wp_reset_postdata(); $all_posts .= '