Php 在wordpress中创建自定义帖子时出错

Php 在wordpress中创建自定义帖子时出错,php,wordpress,Php,Wordpress,WordPress正在抛出此错误消息: 警告:缺少\u x()的参数2,在第8行的“directory/posttypes.php”中调用,在第250行的“directory/l10n.php”中定义 postypes.php: // Add new post type for Recipes add_action('init', 'cooking_recipes_init'); function cooking_recipes_init() { $args = arr

WordPress正在抛出此错误消息:

警告:缺少
\u x()
的参数2,在第8行的“directory/posttypes.php”中调用,在第250行的“directory/l10n.php”中定义

postypes.php:

        // Add new post type for Recipes
add_action('init', 'cooking_recipes_init');
function cooking_recipes_init() 
{
    $args = array(
        'label' => _x('Recipes'),
        'singular_label' => _x('Recipe'),
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true, 
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','comments')
    ); 
    register_post_type('recipes',$args);
}
functions.php:

include_once(ABSPATH . 'wp-content/themes/twentyeleven-child/posttypes.php');
l10n.php:

function _x( $text, $context, $domain = 'default' ) {
    return translate_with_gettext_context( $text, $context, $domain );
}
任何建议都将不胜感激,因为错误表明,该函数有两个必需参数:(1)要翻译的文本字符串,(2)翻译人员的上下文信息

如果不需要包含上下文,可以使用。如果不需要翻译字符串,请不要使用任何函数

以下任一项均有效:

'label' => __('Recipes'),
'singular_label' => __('Recipe'),
或者

在错误状态下,函数有两个必需的参数:(1)要翻译的文本字符串,(2)翻译人员的上下文信息

如果不需要包含上下文,可以使用。如果不需要翻译字符串,请不要使用任何函数

以下任一项均有效:

'label' => __('Recipes'),
'singular_label' => __('Recipe'),
或者

在错误状态下,函数有两个必需的参数:(1)要翻译的文本字符串,(2)翻译人员的上下文信息

如果不需要包含上下文,可以使用。如果不需要翻译字符串,请不要使用任何函数

以下任一项均有效:

'label' => __('Recipes'),
'singular_label' => __('Recipe'),
或者

在错误状态下,函数有两个必需的参数:(1)要翻译的文本字符串,(2)翻译人员的上下文信息

如果不需要包含上下文,可以使用。如果不需要翻译字符串,请不要使用任何函数

以下任一项均有效:

'label' => __('Recipes'),
'singular_label' => __('Recipe'),
或者


如果不为gettext提供上下文,为什么要使用x?请改用
\uuuu()
\u e()
。@PaulSelitskas,在这个例子中,你不想使用
\u e()
,因为我们只想
返回翻译后的字符串…而不是
回显它。@rnevius是的,你不会!我刚才指出的是
\uuu>)
/
\u e()
\u x()
/
\u ex()
并不完全相同。您应该将其替换为uu(),但仅适用于发生错误的位置。根据本指南:如果不提供获取文本的上下文,为什么要使用x?使用
\uu()
\u e()
取而代之。@PaulSelitskas,在这种情况下你不想使用
\u e()
,因为我们只想
返回翻译后的字符串…而不是
回显它。@rnevius是的,你不会!我只是指出
\u e()
/
\u e()
\u x()
/
不完全相同。您应该将其替换为uuux(),但仅适用于发生错误的部分。根据本指南:如果不为gettext提供上下文,为什么要使用x?请改用
uuue()
e()
。@PaulSelitskas,您不想使用
e()
在这个例子中,因为我们只想
返回翻译后的字符串…而不是
回显它。@rnevius是的,你不会的!我只是指出
\uuuuu()
/
\ue()
\ux()
/
\uex()
不完全相同。你应该用uuuu()
u e()
。@PaulSelitskas,您不想使用
e()
在这个例子中,因为我们只想
返回翻译后的字符串…而不是
回显它。@rnevius是的,你不会的!我只是指出
\uuuuu()
/
\ue()
\ux()
/
\uex()
不完全相同。你应该用