Home › Forums › Backend Issues (wp-admin) › Translate post_type in realtionship UI
Hi. Im building a website with a danish admin. Everything seems to work fine in danish, except the post_type name in the Relationship UI. I have looked into the code in the plugins relationship.php. And its obvious that they use the get_post_type() to echo out the right aligned title.
I could hack this, by changing line 294:
$title .= get_post_type();
To:
$post_type_object = get_post_type_object( get_post_type( $post ) );
$title .= $post_type_object->labels->singular_name;
But this means “Hacking the plugin” – which i dont prefer doing.
Is there another way for me to achieve this same result? its seems obvious to me that this would be a better way of insuring translated admins?
Thanks for the issue. I’ll look into this and push a fix to the github repo soon.
Thanks
E
Thanks again for your issue and your fix.
I have pushed this fix to the core!
Thanks
E
Hi elliot – thank you so much! Amazing support here!
Note: these changes should also be made to the right side of the UI on line 495, although a little different:
changing:
$title .= $p->post_type;
To:
$post_type_object = get_post_type_object( get_post_type( $p ) );
$title .= $post_type_object->labels->singular_name;
And also in the “select”, where you can select a posttype. Current code looks like this around line 451:
foreach( $field['post_type'] as $post_type )
{
$choices[ $post_type ] = $post_type;
}
Im not completely sure what the best way would be here, as i don’t quite understand the acf filters.
But that should then fix it for this field, i think. Im impressed with the quick response!
Thanks for the follow up. I’ll look into this soon.
Cheers
E
Thanks again for your work on this.
I’ll leave the post_type
name in the settings as is, but I have added the translate code to the ‘right column’ on the relationship field.
Thanks
E
The topic ‘Translate post_type in realtionship UI’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.