Wordpress - Get posts connected via Rilwis Metabox plugin
//Get posts of another post type connected via Metabox plugin (Rilwis)
$args = array('post_type' => 'custom_post_type', 'meta_query' => array( array('key' => 'custom_field_key') ) );
$posts_with_connection = get_posts($args);
if ($posts_with_connection) {
echo '<section class="class-name"><h1>Heading</h1><ul>';
foreach ( $posts_with_connection as $post_with_connection ) : setup_postdata( $post_with_connection );
$posts_connected2current = rwmb_meta('custom_field_key','type=post&multiple=true',$post_with_connection->ID);
if (in_array($post->ID,$posts_connected2current)) {
echo '<li><a href="'.get_permalink($post_with_connection->ID).'">'.get_the_title($post_with_connection->ID).'</a></li>';
}
endforeach;
echo '</ul></section>';
wp_reset_postdata();
}
//needs Metabox add-a-metabox wrapper code
,array(
'name' => 'Name'
,'id' => $prefix_works . 'connectedpubs'
,'type' => 'post'
,'post_type' => 'publication'
,'multiple' => true
,'field_type' => 'select_advanced'
,'size' => 70
,'placeholder' => 'Type in something'
// ,'query_args' => array(
// 'post_status' => 'publish',
// 'posts_per_page' => - 1,
// )
,'js_options' => array( //see http://select2.github.io/select2/#documentation
'width' => 400
)
)