Hi,
I think no need to use the extension MB Relationship in your case. You can create a custom function to check if the post has a tag ID and then set the category for the post and hook this function to the action save_post
. For example:
add_action( 'save_post', 'set_post_category', 10,3 );
function set_post_category( $post_id, $post, $update ) {
// Only want to set if this is a new post!
if ( $update ){
return;
}
// Only set for post_type = post!
if ( 'post' !== $post->post_type ) {
return;
}
$posttags = get_the_tags( $post_id );
if ( $posttags ) {
foreach( $posttags as $tag ) {
if( $tag->term_id == 12 ) {
wp_set_post_categories( $post_id, [34, 56], true);
}
}
}
}
where 12
is the tag ID, and 34
, 56
is the category IDs.
Read more on the documentation
https://developer.wordpress.org/reference/hooks/save_post/
https://developer.wordpress.org/reference/functions/get_the_tags/
https://developer.wordpress.org/reference/functions/wp_set_post_categories/