WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms + Custom Post Types
Custom Meta fields not showing in custom filed name (4 posts)

  1. madebymartin
    Member
    Posted 1 year ago #

    Hi

    I'm using Jaredatch's Custom Metaboxes & Fields class.
    The custom meta fields that I have created show up and function correctly within my custom post type's editors but do not show in the drop-down list of custom fields within the properties for a custom field section of my forms.

    Anyone else had this problem / come up with a solution?

    http://wordpress.org/extend/plugins/gravity-forms-custom-post-types/

  2. madebymartin
    Member
    Posted 1 year ago #

    Just to add... I have published a post (of the custom post type) that makes use of all custom meta boxes/fields...

  3. John Sundberg
    Member
    Posted 1 year ago #

    madebymartin,

    I'm using Custom Metaboxes and Fields as well, and at first I was adding an underscore to the field IDs to hide them from the post editor custom fields, but that hides the metaboxes from Gravity Forms too. Remove the underscore and you should see them in Gravity Forms.

  4. cgrella
    Member
    Posted 10 months ago #

    Yes, custom meta boxes uses the prefix _cmb_ to hide the fields from custom field list in post editor. They're saved, they just dont show in list. This is commented fairly well in the example-functions file that is included with CMB.

    Like John says, just delete that underscore before CMB in the file you use to register the meta boxes, and then again if you're calling the boxes to be seen on the front end - like in a template page.

    If anyone else is looking at this and thinking "I did all that but the fields are still not showing in my custom post type" make sure that your custom post type is registered to support custom fields.

    That line in your custom post registration code will be like this:

    <?php
    
    add_action( 'init', 'register_cpt_careerops' );
    
    function register_cpt_careerops() {
    
        $labels = array(
            'name' => _x( 'Career Opportunities', 'careerops' ),
            'singular_name' => _x( 'Career Opportunity', 'careerops' ),
            'add_new' => _x( 'Add New', 'careerops' ),
            'add_new_item' => _x( 'Add New Career Opportunity', 'careerops' ),
            'edit_item' => _x( 'Edit Career Opportunity', 'careerops' ),
            'new_item' => _x( 'New Career Opportunity', 'careerops' ),
            'view_item' => _x( 'View Career Opportunity', 'careerops' ),
            'search_items' => _x( 'Search Career Opportunities', 'careerops' ),
            'not_found' => _x( 'No career opportunities found', 'careerops' ),
            'not_found_in_trash' => _x( 'No career opportunities found in Trash', 'careerops' ),
            'parent_item_colon' => _x( 'Parent Career Opportunity:', 'careerops' ),
            'menu_name' => _x( 'Career Opportunities', 'careerops' ),
        );
    
        $args = array(
            'labels' => $labels,
            'hierarchical' => false,
    
            'supports' => array( 'title', 'author', 'revisions', 'page-attributes','custom-fields' ),
    
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'menu_position' => 5,
    
            'show_in_nav_menus' => true,
            'publicly_queryable' => true,
            'exclude_from_search' => false,
            'has_archive' => true,
            'query_var' => true,
            'can_export' => true,
            'rewrite' => true,
            'capability_type' => 'post'
        );
    
        register_post_type( 'careerops', $args );
    }
    ?>

    Third line in the $arg array starts with support. make sure custom-fields is in there.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.