Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to add a new post type

i have a php file (posttype.php) at : wordpress/wp-content/themes/

this is the code :

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

i have a problem at the top of the page (but the posttype is created suc) :

Warning: Missing argument 2 for _x(), called in D:\xampp\htdocs\wordpress\wp-content\themes\posttypes.php on line 12 and defined in D:\xampp\htdocs\wordpress\wp-includes\l10n.php on line 189

Warning: Missing argument 2 for _x(), called in D:\xampp\htdocs\wordpress\wp-content\themes\posttypes.php on line 14 and defined in D:\xampp\htdocs\wordpress\wp-includes\l10n.php on line 189

Thank you .

share|improve this question
put that code INTO the theme, not outside...(/wp-content-themes/YOURTHEME/functions.php ) is a better practice to place into functions. If you code doesn't have erros, it should work – andrewkthx Jan 28 '12 at 20:16

1 Answer

_x() requires a context, either remove it completely or set it to something like 'Recipe Singular' and 'Recipe Plural'.

Docs: _x()

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.