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()'是不完全一樣的。 –