简体   繁体   English

在wordpress错误中创建自定义帖子

[英]Creating custom post in wordpress error

WordPress is throwing this error message: WordPress抛出此错误消息:

Warning: Missing argument 2 for _x() , called in "directory/posttypes.php" on line 8 and defined in "directory/l10n.php on line 250 警告:缺少_x()参数2,在第8行的“ directory / posttypes.php”中调用并在第250行的“ directory / l10n.php”中定义

postypes.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: functions.php:

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

l10n.php: l10n.php:

function _x( $text, $context, $domain = 'default' ) {
    return translate_with_gettext_context( $text, $context, $domain );
}

any advice would be much appreciated, thanks 任何建议将不胜感激,谢谢

As the error states, the _x() function has two required parameters: (1) the string of text to be translated, (2) context information for the translators. 作为错误状态, _x()函数具有两个必需参数:(1)要翻译的文本字符串,(2)转换器的上下文信息。

If you don't need to include context, you can use __() . 如果不需要包含上下文,则可以使用__() If you don't need to translate the string...don't use either function. 如果您不需要翻译字符串...请不要使用任何一个函数。

Either of the following would be valid: 以下任何一项均有效:

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

or... 要么...

'label' => 'Recipes',
'singular_label' => 'Recipe',

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM