Posted By

lfatr on 03/23/11


Tagged

wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vrob


custom screen example ( adds a new menu to the wordpress admin )


 / Published in: PHP
 

URL: http://wordpress.org/support/topic/functionsphp-not-recognizing-add_meta_box

  1. // in theme/functions.php
  2.  
  3. add_action('init', 'jtd_custom_post_types');
  4. function jtd_custom_post_types() {
  5. $labels = array(
  6. 'name' => _x('Cards', 'post type general name'),
  7. 'singular_name' => _x('Card', 'post type singular name'),
  8. 'add_new' => _x('Add New', 'card'),
  9. 'add_new_item' => __('Add New Card'),
  10. 'edit_item' => __('Edit Card'),
  11. 'new_item' => __('New Card'),
  12. 'view_item' => __('View Card'),
  13. 'search_items' => __('Search Cards'),
  14. 'not_found' => __('No cards found'),
  15. 'not_found_in_trash' => __('No cards found in Trash'),
  16. 'parent_item_colon' => ''
  17. );
  18. $args = array(
  19. 'labels' => $labels,
  20. 'menu_position' => 30,
  21. 'public' => true,
  22. 'query_var' => true,
  23. 'supports' => array( 'title', 'editor', 'comments', 'revisions', 'author', 'excerpt', 'custom-fields', 'page-attributes', 'thumbnail' ),
  24. 'rewrite' => array( 'slug' => 'provider', 'with_front' => false ),
  25. 'taxonomies' => array( 'post_tag', 'category'),
  26.  
  27. );
  28. register_post_type('card',$args);
  29. };
  30.  
  31. // This function tells WP to add a new "meta box"
  32. function add_some_box() {
  33. add_meta_box(
  34. 'ozh', // id of the <div> we'll add
  35. 'My Box', //title
  36. 'add_something_in_the_box', // callback function that will echo the box content
  37. 'card' // where to add the box: on "post", "page", or "link" page
  38. );
  39. }
  40. // This function echoes the content of our meta box
  41. function add_something_in_the_box() {
  42. echo "I'm living in a box";
  43. }
  44. // Hook things in, late enough so that add_meta_box() is defined
  45. if (is_admin())
  46. add_action('admin_menu', 'add_some_box');

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: lfatr on May 5, 2011

thats functions.php

You need to login to post a comment.