I managed to solve this by changing the metabox type of the 3rd party plugin with an Ajax based select search.
In the exemple below I’m not using title anymore to filter the select but instead im directly inserting the URL of the post I need (artist/album in this case).
I know this is a workaround, but it works for my case and in hope it can help someone else, theres the code:
in metabox.php
'fields' => array(
array(
'name' => __( 'Artist URL', 'theme' ),
'id' => $prefix."artist_name",
'type' => 'autocomplete',
'options' => admin_url( 'admin-ajax.php?action=artist_list' ),
),
...
Then in functions.php
function get_ajax_artist_list() {
$s = $_REQUEST[ 'term' ];
$post_name = str_replace('https://www.example.com/artist/', '', $s);
$post_name = substr($post_name, 0, -1);
$args = array(
'name' => $post_name,
'post_type' => 'artist',
'post_status' => 'publish',
'numberposts' => 1
);
$my_posts = get_posts($args);
$response = array(
array( 'value' => $my_posts[0]->ID, 'label' => $my_posts[0]->post_title ),
);
echo wp_json_encode( $response );
die;
}
add_action( 'wp_ajax_artist_list', 'get_ajax_artist_list');
Thanks to @Tom J Nowell for the support.