How to load theme textdomain from plugin?

You are completely loading your language file wrong in your plugin, and your file naming is also wrong.

load_theme_textdomain('my_plugin', plugin_dir_path( __FILE__ ) . '/languages');

should be

load_plugin_textdomain('my_plugin', false, dirname(plugin_basename(__FILE__)) . '/lang/');

Also, your mo and po files should be named my_plugin-en_US.mo and my_plugin-en_US.po. Go have a look at this tutorial also, this will help you out a lot.

Leave a Comment