5

(I have some experience creating Wordpress themes but no experience in extending Wordpress functionality. I'm sure this must be a very common question, but I don't know how to search for the answer. All I could find is how to create custom menu items.)

How can I create custom object types / entities in the database, like

  • Team members, i.e. an entry for each team member of the company
  • Reference projects, i.e. an entry for each project the company has done

In the admin panel, it looks like this:

enter image description here

For each object type, I want to define what properties they have (title, name, description, notes, image 1, image 2).

How can I do that? For what keywords should I search?

  • 2
    Check these two plugins. Custom Post Type UI and ACF – Nilambar Aug 22 '14 at 7:35
  • 2
    I'm not sure if I'm getting you on this, but you can make use of the build in custom fields functionality to achieve this. Just make sure it is enableb in the screen options in the add new page – Pieter Goosen Aug 22 '14 at 7:41
3

I think what you want is to create what WorpPress calls "Custom Post Types". Please have a look at the Post Type page in the Codex that explains what Post Types are and how to create custom ones.

Basically, here is the code to create the Object custom post type :

add_action( 'init', 'create_post_type' );
function create_post_type() {
  register_post_type( 'object',
    array(
      'labels' => array(
        'name' => __( 'Objects' ),
        'singular_name' => __( 'Object' )
      ),
    'public' => true,
    'has_archive' => true,
    )
  );
}

A side note : in your screenshot, the WordPress version seams very old (3.3 or something). Please Upgrade to the latest version to take advantage of the new features.

  • Thanks for the hint. Where do I need to insert this code? Do plugins like ACF and Custom Post Type UI do the same? – cheeesus Aug 22 '14 at 8:13
  • You can insert this code either in a plugin or in the functions.php of your theme. And yes, other plugins use this code with a lot of stuff around to have all the options available in the backend UI. – Fabien Quatravaux Aug 22 '14 at 8:22
  • @FabienQuatravaux: I don't recommend putting this functionality in functions.php because you are tying function with display. Do you really want to lose your custom object entity if you switch themes because you want your site to look different? Or have to copy it to each theme you use? – User Jun 26 '16 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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