Translate theme's string on custom post type pages

Please advise, how to translate a theme string on custom post types pages

  • Panos

    Hi Ash ,

    If you need to use Ultimate Branding's module Network Wide Text Change specifically on a custom post type, you can modify file:
    wp-content/plugins/ultimate-branding/ultimate-branding-files/modules/site-wide-text-change.php

    and in line 347 add:

    if( ! $post instanceof WP_Post || $post->post_type != "YOUR CPT HERE" ){
    				return $transtext;
    		}

    This however will allow any text to be translated at custom post types page only. If you find this restricting, you may try out a solution like the one here:
    https://gist.github.com/wpmudev-sls/32e0d53a4a7be7762ae36281cd3171f7

    You can download file, change the YOUR CPT to your custom post type also set the replacements strings in the replacements() method.

    For theme Twenty Seventeen the text domain is twentyseventeen. You will need to replace that with the textdomain of your theme. You can then start inserting the strings you need to replaced and their replacements in that array.

    That array contains a sub-array with default. This is only to demonstrate that you are not limited to theme only. In case you only need theme though, simply remove that sub-array.

    Once done editing you can upload file to wp-content/mu-plugins folder ( if that folder doesn't exist you can simply create it ).

    Hope this helps :slight_smile:

    Cheers!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.