2

我有一个问题,我想使用子主题加载文本域。子主题中的功能页面仅包含以下代码。

<?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' );
}

这是父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');

我希望能帮助我解决这个问题,我尝试挂钩其他一些功能,但它似乎也不起作用,但是当我离开 } 或 ) 或 ; 在子function.php中我得到一个错误,这意味着子文件可执行文件中的function.php,但我不知道为什么它没有任何工作。

子主题中的语言文件夹包含以下文件:

poseidon.pot
ar.po
ar.mo
4

1 回答 1

0

您必须改用父级的文本域:

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

从 wordpress 文档中看到这个。

于 2018-07-07T22:15:27.143 回答