• sorry this is my first post ,but also note that this is my first day in WP. I am watching one lynda.com tutorials to learn how to set up one profile site with WP. In the process the instructor describe how to add New Items like post and he use one functions to do this . here is the code for this one.
    [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);
    }

    ?>[/code]

    this file is called “functions.php” and there is also one include file which include this functions.php file with this [code]<?php

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

    ?>[/code]

    Now when I do this and refresh the admin page or the site I got two error. Here is the errors I get

    Warning: Missing argument 2 for _x(), called in C:\wamp\www\wordpress\wp-content\themes\posttypes.php on line 9 and defined in C:\wamp\www\wordpress\wp-includes\l10n.php on line 189

    Warning: Missing argument 2 for _x(), called in C:\wamp\www\wordpress\wp-content\themes\posttypes.php on line 10 and defined in C:\wamp\www\wordpress\wp-includes\l10n.php on line 189

    Being a new person I could not understand how to solve this. The video I am watching show this one correctly. They are using WP 3.3 and I am using WP 3.3.1. Is that make the difference. Please help and guide me.

    Thanks.

    trnghosh

Viewing 2 replies - 1 through 2 (of 2 total)
  • Function Reference for _x()

    Missing context information for text language translation. If you’re just learning WordPress then I would say just get rid of it. ie ‘label’ => ‘Recipes’. It’s not necessary to get the post type registered.

    Thread Starter trnghosh

    (@trnghosh)

    Now my code is

    <?php

    // Add new post type for Recipes
    add_action(‘init’, ‘cooking_recipes_init’);
    function cooking_recipes_init()
    {
    $args = array(
    ‘label’ => (‘Recipes’),
    ‘singular_label’ => (‘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);
    }
    ?>

    And God it works!! OH! I am really perplexed to get your help. Stuck here for two days.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding New Post’ is closed to new replies.