WordPress.org

Ready to get started?Download WordPress

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: 9 months 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: 9 months 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: 9 months ago #
  4. juanvillegas
    Member

    12345

    Advanced Custom Fields plugin does exactly this..

    Posted: 8 months ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    7 Votes
  • Status

    This idea is under consideration