WordPress.org

Ideas

Core solution for (advanced) custom fields

  1. Mihail Semjonov
    Member

    Hello,

    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 (
          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'
          ),
          array(
            '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: 1 year ago #
  2. crstauf
    Member

    12345

    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: 1 year ago #
  3. Nashwan Doaqan
    Member

    12345

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

    Momtaz Nmwdhj
    http://wordpress.org/plugins/momtaz-nmwdhj/

    WP Forms API
    https://github.com/jbrinley/wp-forms

    Posted: 1 year ago #
  4. juanvillegas
    Member

    12345

    Advanced Custom Fields plugin does exactly this..

    Posted: 1 year ago #
  5. khalm
    Member

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

    Posted: 11 months ago #
  6. Asapy
    Member

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

    Posted: 11 months ago #
  7. Oxagile
    Member

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

    Posted: 10 months ago #
  8. juanvillegas
    Member

    12345

    @oxagile have you checked Advanced Custom Fields plugin?

    Posted: 10 months ago #
  9. Oxagile
    Member

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

    Posted: 10 months ago #
  10. flashbay
    Member

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

    Posted: 7 months ago #

RSS feed for this topic

Reply »

You must log in to post.

  • Rating

    12345
    7 Votes
  • Status

    This is plugin territory