Last active
June 3, 2021 19:33
-
-
Save cristianstan/9cec1e17fe4cc2174a481ccb21ce66ba to your computer and use it in GitHub Desktop.
CM2 default post id with suffix or prefix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// CMB2 with Prefix | |
function prefix_default_offer_id_by_offer_id( $field_args, $field ) { | |
return 'prefix_'. $field->object_id; | |
} | |
$cmb->add_field( array( | |
'name' => esc_html__( 'Nr. Oferta', 'cmb2' ), | |
'id' => 'woopog_offer_id', | |
'type' => 'text', | |
// 'default' => '', | |
'default_cb' => 'prefix_default_offer_id_by_offer_id', | |
) ); | |
// CMB2 with Suffix | |
function suffix_default_offer_id_by_offer_id( $field_args, $field ) { | |
return $field->object_id.'_suffix'; | |
} | |
$cmb->add_field( array( | |
'name' => esc_html__( 'Nr. Oferta', 'cmb2' ), | |
'id' => 'woopog_offer_id', | |
'type' => 'text', | |
// 'default' => '', | |
'default_cb' => 'suffix_default_offer_id_by_offer_id', | |
) ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment