• Resolved artotal

    (@artotal)


    Hi,
    – WordPress 3.6 :
    – PHP 5 / MySQL :
    – child theme of thirteen :
    – no extensions :
    – I use localhost :

    Problem :
    I do a blog with different type of post with personelize !
    I added in admin a new menu “recepies”.
    When I created a new recepies, I have a 404 error, why didn’t works ?
    this is my code :

    // Add new post type for Recipes
      4 add_action('init', 'cooking_recipes_init');
      5 function cooking_recipes_init()
      6 {
      7   $recipe_labels = array(
      8     'name' => _x('Recipes', 'post type general name'),
      9     'singular_name' => _x('Recipe', 'post type singular name'),
     10     'all_items' => __('All Recipes'),
     11     'add_new' => _x('Add new recipe', 'recipes'),
     12     'add_new_item' => __('Add new recipe'),
     13     'edit_item' => __('Edit recipe'),
     14     'new_item' => __('New recipe'),
     15     'view_item' => __('View recipe'),
     16     'search_items' => __('Search in recipes'),
     17     'not_found' =>  __('No recipes found'),
     18     'not_found_in_trash' => __('No recipes found in trash'),
     19     'parent_item_colon' => ''
     20   );
     21   $args = array(
     22     'labels' => $recipe_labels,
     23     'public' => true,
     24     'publicly_queryable' => true,
     25     'show_ui' => true,
     26     'query_var' => true,
     27     'rewrite' => true,
     28     'capability_type' => 'post',
     29     'hierarchical' => false,
     30     'menu_position' => null,
     31     'supports' => array('title','editor','comments')
     32   );
     33   register_post_type('recipes',$args);
     34 }

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • If your site is already set up and you add a new post type like that your permalinks won’t have caught up wth the new addition. To get around this, go to the permalinks area in your admin and reset it by changing to ‘default’ and saving, and then back to your current setting and saving again. This will let your new post type show up correctly.

    Thread Starter artotal

    (@artotal)

    Thanks, that’s works ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add new post type’ is closed to new replies.