I wager the “text” field type would be the “large” equivalent. https://github.com/WebDevStudios/CMB2/wiki/Field-Types
https://cloudup.com/cg4uAUqPGTS from “text” to “text_small”
Should be able to hook in your own CSS and override if necessary. I’d recommend admin_enqueue_script https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts with a low priority or perhaps admin_head
What you’re talking about can be accomplished via the attributes field property:
$cmb->add_field( array(
'name' => 'Test Text',
'desc' => 'field description (optional)',
'default' => 'standard value (optional)',
'id' => 'wiki_test_text',
'type' => 'text',
'attributes' => array(
'style' => 'width:25%;',
),
) );
Thanks Michael and Justin, this is very helpful!
Hi there,
I am here having difficulty to load my custom css after the default cmb2-style.css
<link rel='stylesheet' id='cmb2-override-css' href='http://localhost/.../cmb2-style.css?ver=4.3.1' type='text/css' media='all' />
<link rel='stylesheet' id='cmb2-styles-css' href='http://localhost/..
Here’s what my functions look like
function load_custom_wp_admin_style() {
wp_register_style( 'cmb2-override', get_template_directory_uri() . '/admin/cmb2-style.css');
wp_enqueue_style( 'cmb2-override' );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
By the way, if I would like to load the custom-style only when there are cmb2 custom fields which page should I target?
Thanks!
@srmahmud2: If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else’s. This topic is 3 months old & has been resolved, so will no longer be monitored by the plugin’s author.
Hi esmi,
Thanks for remindere. I was a little confuse should comment here or where. Never mind mean I have resolved one of my issue.
Will post the rest as prescribed.
Regards.
with your wp_register_style, put “cmb2-styles” as a dependency for your own CSS file. That should force them to be loaded after CMB2’s.
You’d need to do some sort of current screen checking to conditionally load the CSS file itself. Not sure offhand where in the admin this is meant for, meaning post editor pages, options page, etc.
Thanks for you prompt reply.
any one who comes later please follow this thread hear how to float left text-fields one another and adding placeholder instead of label.
If you want to remove the field names, you can specify 'show_names' => false on the metabox config array: https://github.com/WebDevStudios/CMB2/blob/master/example-functions.php#L87