Core solution for (advanced) custom fields

  1. Mihail Semjonov


    The idea is to make some custom fields that can be added to post (post_types) that will be defined on all (custom post type) pages.

    For example text, number, image, color picker, date atc. most used field types for development.

    How it's working now:
    you add custom post type with enabled custom fields and you have to manually create the id and write the value of it on edit screen.
    The main problem is that you have to manually for each post choose id, and enter a value..

    What i'm suggesting is:
    when you create custom post type you may specify what custom fields should be there by default.

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'book' ),
        'capability_type' => 'post',
        'has_archive' => true,
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )

    what will be new:

    'custom_fields' => array (
          'id' => 'date', // id that is key for DB
          'name' => 'Select a date', // the name that is displayed so you could understand what field is it for.
          'type' => 'datepicker', // one of the defaults
          'options' => 'd.m.Y', // specifies the values or how it must be set in edit screen
          'default' => '00.00.0000'
            'id' => 'product_type', // id that is key for DB
            'type' => 'select', // one of the defaults
            'options' => array(
               'value1' => 'display1', // where value1 is the value of option and display1 is a text in option tag
               'value2' => 'display2',
            'default' => 'value2'

    and that will automaticaly create 2 fields.. first - date picker and seccond - select that will contain 2 options (and 2 option is by default);

    I think this kind of adding custom field would save a lot of time to developers.

    Posted: 4 years ago #
  2. crstauf


    if you're looking to automate custom post meta box (cpmb) generation, that should be pretty easy to do through a plugin... or you could even write a simple function (no admin) that you pass the array to, and it creates everything.

    definitely not core material.

    Posted: 4 years ago #
  3. Nashwan Doaqan


    I think you are looking for a "Forms API", You can do this by your own functions or other projects like:

    Momtaz Nmwdhj

    WP Forms API

    Posted: 4 years ago #
  4. juanvillegas


    Advanced Custom Fields plugin does exactly this..

    Posted: 4 years ago #
  5. khalm

    This is realy for a plugin, not a core function.

    Posted: 3 years ago #
  6. Asapy

    I'm aslo think that it will be best to make plugin for this. It is not so urgent for core function.

    Posted: 3 years ago #
  7. Oxagile

    Is there any plugin versions ready? Or at least is the idea still under consideration?

    Posted: 3 years ago #
  8. juanvillegas


    @oxagile have you checked Advanced Custom Fields plugin?

    Posted: 3 years ago #
  9. Oxagile

    No. Saw your reply earlier in the thread, and I think I'll give it a try.

    Posted: 3 years ago #
  10. flashbay

    What juan said, i use it mysel, Advanced Custom Fields plugin

    Posted: 3 years ago #

RSS feed for this topic

Reply »

You must log in to post.

  • Rating

    8 Votes
  • Status

    This is plugin territory