Translate CPT SEO Titles & Meta Settings

#5305
  • Resolved kgy
    Rank Math free

    How I can make a custom titles fro every languages, also CPT titles not shown in string translation section.
    Is there a separate settings for every language?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    You need to create a new version of the page for each language to be able to translate the titles for each page. There is a however an issue with URLs syncing between the different languages but we have fixed this internally, a fix for this will be available soon.
    As for the other issue, would you mind letting me know how you have registered the CPT, is this through a plugin or using PHP in your functions.php file?
    You may need to check if the strings are wrapped in __( ‘text’, ‘mytextdomain’ ) function.

    Looking forward to helping you. Thank you.

    ​​​​​​​

    kgy
    Rank Math free

    Thanks,
    I mean the global title options from SEO Titles & Meta section, not manually by single post.
    I created CPT manually, but I need to put any text domain in mytextdomain?

    Hi there,

    Thanks for the clarification.

    In this case, you can make use of the following filter to create new variables for use on the titles:

    /**
     * Filter to add custom variables
     */
    add_filter( 'rank_math/vars/replacements', function( $vars ) {
    	return $vars;
    });

    Yes you can use a custom text domain if you want to handle the translations yourself.

    I hope this info helps. Thank you.

    kgy
    Rank Math free

    Thanks, Please give me an example of how I can use this filter for custom CPT titles

    Hi there,

    Thanks for the follow up.

    Here is an example of replacing the default title that will be displayed when the %title% variable is used on the global settings:

    /**
     * Filter to replace wc_brand with custom value.
     */
    add_filter( 'rank_math/replacements', function( $replacements ) {
        if ( is_singular() && isset( $replacements['%title%'] ) ) {
            //this example gets the title from a custom field value
            $title = get_post_meta( get_the_ID(), '_custom_post_meta', true ); // Replace _custom_post_meta with your meta key.
            $replacements['%title%'] = $title; // Pass $title to set meta value.
        }
        return $replacements;
    });

    I hope this info helps. Thank you.

    kgy
    Rank Math free

    Sorry, I put this code on my functions.php and nothing happened.
    and where I can use this lines? putting them in functions return errors.

    global $post;
            $title = RankMath\Post::get_meta( 'title', $post->ID );
            if ( '' !== $title ) {
                return $title;
            }

    Thank you.

    Hi there,

    Thanks for the follow up.

    The second part is actually not necessary, I have edited my post. Please note that this code was to serve as an example and is not complete. To make it work, you need to have a custom field on the post and then replace it’s meta key with this ‘_custom_post_meta’ on the code.
    Th function will then load the value of this custom field as a replacement.

    I hope this info helps.

    kgy
    Rank Math free

    Thank you very much, it works.

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/?rate=5#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)

The ticket ‘Translate CPT SEO Titles & Meta Settings’ is closed to new replies.