0
WordPress是引发此错误消息:创建自定义后
警告:缺少论据2
_x()
,称为“目录/ posttypes.php”上线8和“目录/本地化定义。上的PHP线250
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);
}
任何建议将不胜感激,感谢
为什么使用_x,如果你不提供上下文的getText?使用'__()'或'_e()'代替。 –
@PaulSelitskas,你不希望使用'_e()'在这种情况下,因为我们只想'return'翻译串......不是'echo'它。 – rnevius
@rnevius是你不会的!我只是指出'__()'/'_e()'和'_x()'/'_ex()'是不完全一样的。 –