Nuxy
Search…
Adding Post Options
Modify your post/custom post type with brand new settings
WordPress powered with Post Type meta boxes. Add Meta Box to the desired post type with a unique ID.
1
add_filter('stm_wpcfto_boxes', function ($boxes) {
2
3
$boxes['my_metabox'] = array(
4
'post_type' => array('post', 'my-custom-post-type'),
5
'label' => esc_html__('Post settings', 'my-domain'),
6
);
7
8
return $boxes;
9
});
Copied!
And we need to add fields to this Meta Box:
1
add_filter('stm_wpcfto_fields', function ($fields) {
2
3
$fields['my_metabox'] = array(
4
5
'tab_1' => array(
6
'name' => esc_html__('Field Settings', 'my-domain'),
7
'fields' => array(
8
'field_1' => array(
9
'type' => 'text',
10
'label' => esc_html__('Field text', 'my-domain'),
11
),
12
)
13
),
14
15
);
16
17
return $fields;
18
});
Copied!

Custom Fields

You can easily use default WordPress functions such as get_post_meta(), get_option() or get_term_meta(). But for the option we built-in function to get any param you want:
1
$options = stm_wpcfto_get_options('my_awesome_settings');
Copied!
Last modified 11mo ago
Copy link