Thread Starter
madvic
(@madvic)
Just add post_id in post_parent field of the attached image. 😉
Thread Starter
madvic
(@madvic)
Here the code :
metabox.php line 79 :
$img_ids = explode(",", $value);
$value = implode( ',', (array)$value );
if ( get_post_meta( $post->ID, $key, FALSE ) ) {
update_post_meta( $post->ID, $key, $value );
foreach ( $img_ids as $id ) {
wp_update_post( array( 'ID' => $id,'post_parent' => $post->ID ) );
}
} else {
add_post_meta( $post->ID, $key, $value );
foreach ( $img_ids as $id ) {
wp_update_post( array( 'ID' => $id,'post_parent' => $post->ID ) );
}
}
Hi madvic. Thanks for the suggestion and more importantly for actually writing some code. I’m sorry for not responding quickly. I don’t get notifications and it’s hard to remember to check frequently.
I don’t have a lot of time right now, but I’ll try to make some time to read through your code in depth this week.
I’m working on a redesign of the metabox from scratch to make it more similar to how the Media page itself works. This should be part of the redesign.