2
votes

I have problem that I want to load textdomain using child theme.. the function page in the child theme contains only the following code.

<?php
add_action( 'after_setup_theme', 'poseidon_child_setup');
function poseidon_child_setup() {

// Poseidon theme for translation
load_child_theme_textdomain( 'poseidon-child', get_stylesheet_directory() . '/languages' );
}

and this is a part of code of the parent function.php

if (!function_exists('poseidon_setup')) :

/**
 * Sets up theme defaults and registers support for various WordPress features.
 *
 * Note that this function is hooked into the after_setup_theme hook, which
 * runs before the init hook. The init hook is too late for some features, such
 * as indicating support for post thumbnails.
 */
function poseidon_setup() {

    // Make theme available for translation. Translations can be filed in the /languages/ directory.
    load_theme_textdomain('poseidon', get_template_directory() . '/languages');

    // Add default posts and comments RSS feed links to head.
    add_theme_support('automatic-feed-links');

    // Let WordPress manage the document title.
    add_theme_support('title-tag');

    // Enable support for Post Thumbnails on posts and pages.
    add_theme_support('post-thumbnails');

    // Set detfault Post Thumbnail size.
    set_post_thumbnail_size(840, 560, true);

    // Register Navigation Menu.
    register_nav_menu('primary', esc_html__('Main Navigation', 'poseidon'));

    // Switch default core markup for search form, comment form, and comments to output valid HTML5.
    add_theme_support('html5', array(
        'comment-form',
        'comment-list',
        'gallery',
        'caption',
    ));

    // Set up the WordPress core custom background feature.
    add_theme_support('custom-background', apply_filters('poseidon_custom_background_args', array('default-color' => 'ffffff')));

    // Set up the WordPress core custom logo feature.
    add_theme_support('custom-logo', apply_filters('poseidon_custom_logo_args', array(
        'height' => 50,
        'width' => 250,
        'flex-height' => true,
        'flex-width' => true,
    )));

    // Set up the WordPress core custom header feature.
    add_theme_support('custom-header', apply_filters('poseidon_custom_header_args', array(
        'header-text' => false,
        'width' => 2500,
        'height' => 625,
        'flex-height' => true,
    )));

    // Add Theme Support for wooCommerce.
    add_theme_support('woocommerce');

    // Add extra theme styling to the visual editor.
    add_editor_style(array('css/editor-style.css', poseidon_google_fonts_url()));

    // Add Theme Support for Selective Refresh in Customizer.
    add_theme_support('customize-selective-refresh-widgets');
}
endif;
add_action('after_setup_theme', 'poseidon_setup');

I hope help me solve this problem, and I tried to hook some other functions but it seems not working too, but when I leaf a } or ) or ; in the child function.php I got an error and that means the function.php in child file executable but I don't know why nothing work in it.

the languages folder in child theme contains these files:

poseidon.pot
ar.po
ar.mo
1

1 Answers

0
votes

You have to use the parent's text domain instead:

// Poseidon theme for translation
load_child_theme_textdomain( 'poseidon', get_stylesheet_directory() . '/languages' );

See this from wordpress docs.