Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. add_action('mb_relationships_init', function () {
  2.     $post_id = null;
  3.     if ( isset( $_GET['post'] ) ) {
  4.         $post_id = intval( $_GET['post'] );
  5.     } elseif ( isset( $_POST['post_ID'] ) ) {
  6.         $post_id = intval( $_POST['post_ID'] );
  7.     }
  8.  
  9.     global $wpdb;
  10.     $filteredIds = $wpdb->get_col( $wpdb->prepare( 'SELECT `from` FROM wp_mb_relationships WHERE wp_mb_relationships.to = %s', $post_id ) );
  11.  
  12.     MB_Relationships_API::register(array(
  13.         'id' => 'p2p',
  14.         'from' => array(
  15.             'type' => 'post',
  16.             'post_type' => 'post',
  17.             'admin_column' => true,
  18.             'meta_box' => [
  19.                 'title' => 'Pages'
  20.             ],
  21.             'query_args' => [ 'post__in' => $filteredIds ],
  22.         ),
  23.         'to' => array(
  24.             'type' => 'post',
  25.             'post_type' => 'page',
  26.             'meta_box' => [
  27.                 'title' => 'Posts'
  28.             ],
  29.         ),
  30.     ) );
  31. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement