text:date picker – "non-repeat" function failing
-
Just created simple “duration” box with only two fields. both are the text:date picker type – one for “begin” and the other for “end”. Neither have the “repeatable” box checked!
Still, when used to enter a post, the first instance (ie begin date) always shows an “add” button (meaning it’s been created as repeatable); while the second instance (end date) does what it’s supposed to do – ie be a single simple entry.
No matter what I do I cannot remove the “add” button – I don’t want it to be repeatable, there is only one begin and end date – I don’t want users to think they can add two.
what do I do now?
-
Please provide your entire box/field registration code.
Agreeing with Justin, having all of the code you’re using for this would help out a lot.
Justin, Michael – Really, I don’t think I know what you are asking for. I’m merely using the GUI you’ve programmed into the plugin to9 fill out boxes. I’ve created a box called “duration”. I’ve entered the title “begin” and “date began” into the name and description boxes of “field 1”. I’ve selected “text_date:Date Picker” for the field type. I MAKE SURE that the “repeatable” box is NOT checked. There is no entry in either the “options” or the “default value” boxes.
I added a “field 2” box with absolutely identical settings except named “End” and described “Date ended.”
The metabox settings in the sidebar are”
Post Types: “Engrams” and “passages” (two custom post types)
Priority: “core”
Context: “normal”
Show names: “checked” to show on left
Disable CMB2 Styles: “NOT checked”
Closed by Default: “NOT checked”Is that what you want?
Then when I go to enter either a new “engram” or “Passage” the “Duration” box that I set up using your GUI appears like it should with both “begin” and “end” fields and their “begin” and “End” names on the left.
EXCEPT that the “begin” box has the description above the entry box (the “end” field does NOT) – inconsistency number 1;
the “begin” field has a greyed out “remove” remove box to the right (the “end” field does not – inconsistency number 2;
the “begin” area then has an extra grey horizontal line below which exists another button “Add Row” (the end field does not) – inconsistency number 3.
Also the two fields are separated by another full width horizontal line – which I guess is intended.
This also occurs if I enter a “passages” taxonomy too.
—
Perhaps this is not what you wanted – but I have written no “registration code” that I know of for a “box/field”, only used your GUI – and I thought I gave all this originally only not so succinctly.
Let me know if I’ve missed your point.
Perhaps I could add that until I see whether/how this thing works I’m just setting it up using native worpress and twentysixteen theme (yes, latest updates)
the only “programming” I’ve done has been to add a simple functions-plugin with the taxonomy and custom post type code as thus: (perhaps this is what you mean by “registration”??? Except it is not for “box/field” as you asked for) – basically got this off previous “answers” on the inet and modified it to my content. It seems to be working in every other way with adding real content.
/* ---------------------------------- * * Custom taxonomy - engram classes * * ---------------------------------- */ // hook into the init action and call create_engram_taxonomies when it fires add_action( 'init', 'create_engram_hierarchical_taxonomy', 0 ); function create_engram_hierarchical_taxonomy() { // Add new taxonomy, make it hierarchical like categories // first do the translations part for GUI $labels = array( 'name' => _x( 'Engram Classes', 'taxonomy general name' ), 'singular_name' => _x( 'Class', 'taxonomy singular name' ), 'search_items' => __( 'Search Engram Classes' ), 'all_items' => __( 'All Classes' ), 'parent_item' => __( 'Parent Class' ), 'parent_item_colon' => __( 'Parent Class:' ), 'edit_item' => __( 'Edit Class' ), 'update_item' => __( 'Update Class' ), 'add_new_item' => __( 'Add New Class' ), 'new_item_name' => __( 'New Class Name' ), 'menu_name' => __( 'Engram Classes' ), ); // Now register the taxonomy register_taxonomy('classes',array('post'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'class' ), )); } /* ---------------------------------- * * Custom taxonomy - Periods * * ---------------------------------- */ // hook into the init action and call create_period_taxonomies when it fires add_action( 'init', 'create_period_hierarchical_taxonomy', 0 ); function create_period_hierarchical_taxonomy() { // Add new taxonomy, make it hierarchical like categories // first do the translations part for GUI $labels = array( 'name' => _x( 'Periods', 'taxonomy general name' ), 'singular_name' => _x( 'Period', 'taxonomy singular name' ), 'search_items' => __( 'Search periods' ), 'all_items' => __( 'All Periods' ), 'parent_item' => __( 'Parent Period' ), 'parent_item_colon' => __( 'Parent Period:' ), 'edit_item' => __( 'Edit Period' ), 'update_item' => __( 'Update Period' ), 'add_new_item' => __( 'Add New Period' ), 'new_item_name' => __( 'New Period Name' ), 'menu_name' => __( 'Periods' ), ); // Now register the taxonomy register_taxonomy('periods',array('post'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'period' ), )); } /* END - ADD TAXONOMIES */ /* ADD CUSTOM POST TYPES */ /* -------------------------------------- * * Custom Post Type - Engrams * * -------------------------------------- */ function custom_post_type_engrams() { // Set UI labels for Custom Post Type $labels = array( 'name' => _x( 'Engrams', 'Post Type General Name', 'iRememberMe' ), 'singular_name' => _x( 'Engram', 'Post Type Singular Name', 'iRememberMe' ), 'menu_name' => __( 'Engrams', 'iRememberMe' ), 'parent_item_colon' => __( 'Parent Engram', 'iRememberMe' ), 'all_items' => __( 'All Engrams', 'iRememberMe' ), 'view_item' => __( 'View Engram', 'iRememberMe' ), 'add_new_item' => __( 'Add New Engram', 'iRememberMe' ), 'add_new' => __( 'Add New', 'iRememberMe' ), 'edit_item' => __( 'Edit Engram', 'iRememberMe' ), 'update_item' => __( 'Update Engram', 'iRememberMe' ), 'search_items' => __( 'Search Engram', 'iRememberMe' ), 'not_found' => __( 'Not Found', 'iRememberMe' ), 'not_found_in_trash' => __( 'Not found in Trash', 'iRememberMe' ), ); // Set other options for Custom Post Type $args = array( 'label' => __( 'engrams', 'iRememberMe' ), 'description' => __( 'Single life memories', 'iRememberMe' ), 'labels' => $labels, // Features this CPT supports in Post Editor 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', 'listings'), // You can associate this CPT with a taxonomy or custom taxonomy. 'taxonomies' => array( 'classes' ), /* A hierarchical CPT is like Pages and can have * Parent and child items. A non-hierarchical CPT * is like Posts. */ 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'page', ); // Registering your Custom Post Type register_post_type( 'engrams', $args ); } /* Hook into the 'init' action so that the function containing our post type registration is not * unnecessarily executed. */ add_action( 'init', 'custom_post_type_engrams', 0 ); /* -------------------------------------- * * Custom Post Type - Passages* * -------------------------------------- */ function custom_post_type_passages() { // Set UI labels for Custom Post Type $labels = array( 'name' => _x( 'Passages', 'Post Type General Name', 'iRememberMe' ), 'singular_name' => _x( 'Passage', 'Post Type Singular Name', 'iRememberMe' ), 'menu_name' => __( 'Passages', 'iRememberMe' ), 'parent_item_colon' => __( 'Parent Passage', 'iRememberMe' ), 'all_items' => __( 'All Periods', 'iRememberMe' ), 'view_item' => __( 'View Passage', 'iRememberMe' ), 'add_new_item' => __( 'Add New Passage', 'iRememberMe' ), 'add_new' => __( 'Add New', 'iRememberMe' ), 'edit_item' => __( 'Edit Passage', 'iRememberMe' ), 'update_item' => __( 'Update Passage', 'iRememberMe' ), 'search_items' => __( 'Search Passage', 'iRememberMe' ), 'not_found' => __( 'Not Found', 'iRememberMe' ), 'not_found_in_trash' => __( 'Not found in Trash', 'iRememberMe' ), ); // Set other options for Custom Post Type $args = array( 'label' => __( 'passages', 'iRememberMe' ), 'description' => __( 'A particular part of someone\'s life or career in which something continues to exist or happen', 'iRememberMe' ), 'labels' => $labels, // Features this CPT supports in Post Editor 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', 'listings'), // You can associate this CPT with a taxonomy or custom taxonomy. 'taxonomies' => array( 'periods' ), /* A hierarchical CPT is like Pages and can have * Parent and child items. A non-hierarchical CPT * is like Posts. */ 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'page', ); // Registering your Custom Post Type register_post_type( 'passages', $args ); } /* Hook into the 'init' action so that the function containing our post type registration is not * unnecessarily executed. */ add_action( 'init', 'custom_post_type_passages', 0 ); /* END - ADD CUSTOM POST TYPES */
You haven’t done up anything like https://github.com/WebDevStudios/CMB2/blob/master/example-functions.php#L362-L389, where you instantiate
new_cmb2_box()
and add fields as required? Ignore the detail about the example above being for just an about page, I needed something short for the example ??This is the code we’re referring to wanting to see, so we could set up a matching version on our own and determine what may or may not be going on when trying to use the rendered GUI.
Sounds like you’re using some sort of admin UI plugin for CMB2? If so, you’ll need to take your support inquiry there.
Ah… tag team customer support. I like it.
Justin you win the prize by revealing that your CMB2 doesn’t even have a GUI so what was I thinking? … I waded through the maze of internet posts and google hits that is most of our gateway into trying to deal with the disappointment that WordPress has supported taxonomies for many years and even now still has no basic support for it beyond creating them!
Links from all over the net go to your “old” page with the disclaimer that you’ve upgraded the program – which is what I followed and which makes all of us “uninitiated” a bit wary and watchful of getting the “old/bad” code. There were two listings with CMB2 in the title on the WP Plugin install page and my assumption was that they were both from the same team — evidently wrong.
“CMB2 admin extension” is not yours then, and it didn’t click for me that the “post editor” was still in the “admin” and therefore part of the “extension.” I deactivated that “aberrant” plugin and walla – I get nothing, even though yours is still active.
That was the culprit, but now I’ve got to figure out where it was storing all its code because I’ve already done a lot of work with it. Sorry for wasting all of our time.
Guess I’ve got to start all over. I can’t see me starting from scratch and writing a data entry program to enter custom data on every entry just because I’m using a custom taxonomy name instead of the WP basic “cat” and “tag.”
Perhaps you’ve got a recommendation for a GUI based plugin that will allow custom fields attached to taxonomies – or one more compatible with yours?
Thanks anyway.
— In fairness though, in my google travels I did see the descriptions that you’ve linked to and being full of jargon I didn’t understand many of them. Also, I did copy and paste your functions-example.php into my jedit to try and see what it did, but got two parsing errors (line 2 and line 20) warning “2:statement expected” and “20:statement expected” (I have no clue what that means) — so I thought that the code was probably the “OLD CODE” that you warned about and discarded it.
If you’re looking for a no-code point and click solution, you might want to check out Custom Field Suite: https://www.ads-software.com/plugins/custom-field-suite/
- The topic ‘text:date picker – "non-repeat" function failing’ is closed to new replies.