• I was using a different plugin for Custom Post Types, and am looking at switching this site to use Types instead (since, after all, it’s pretty awesome).

    I completely understand that custom fields created through Types are prefixed with wpcf-, and that’s fine. I still don’t agree with it, but I can accept it 🙂

    Anyway, I’ve been exploring switching control of custom fields to and from types, and it works well, but with one major flaw that I can’t seem to work around: If the existing custom field is prefixed with an underscore, a la _price , it is not selectable in the UI as being able to hand control off to Types.

    I feel like I should be able to hand off these custom fields to Types, and that being prefixed with an underscore shouldn’t be a deal-breaker for that.

    Thoughts? Thanks!

    http://wordpress.org/plugins/types/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi Jason,

    You should change the key to “wpcf-_price” in this case.

    If I was willing to change the custom field name, there would be no issue in the first place (I could also just remove the underscore prefix).

    We have lots of existing code that is based on the custom field being called ‘_price’, so changing it is not a real option. I feel like I should be able to assign control of custom fields to Types regardless of whether or not the custom field starts with an underscore or not.

    Ok, I will need to check it with our development team, will be back soon.

    Awesome – I appreciate your response and further looking into it 🙂

    Some background, in case you or (more likely) another person reading happens to be unfamiliar with why underscores are special:

    Custom Fields that have names prefixed with underscores do NOT appear in the traditional Custom Fields UI provided by core. One should prefix their custom field names with underscores if they are either..

    a) not intended to be controlled by the user

    b) you provide your own, likely more advanced and user-friendly, interface for the custom field (which is the case for us)

    Hi Jason,

    Just to let you know that I’ve already opened a new item on our to do list to fix this issue. It will be available in the next release. Thank you to report it and for your understanding.

    Regards,

    Adriano Ferreira.

    Hi Jason,
    we’re considering to display hidden meta fields on control screen (names with underscore as prefix).

    For now if you can – use workaround:

    This should be performed once and removed from code:

    add_action( 'types_after_init', '__test' );
    function __test(){
        require_once WPCF_ABSPATH . '/includes/fields.php';
        wpcf_types_cf_under_control( 'add',
                array(
            'fields' => array('_price_' . md5( 'wpcf_not_controlled' )),
            'type' => 'textfield'
                )
        );
    }

    Field still won’t be displayed in control screen.
    Can be added to group of fields after that using group edit screen.
    Tested for basic functionality – adding, inserting shortcode, rendering.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘wpcf- prefix, underscore-prefixed fields, and Types control’ is closed to new replies.