I am creating a child theme using the storefront as a parent theme so far I am doing well, I am trying to create a website where I can change the basic aspects of the style of the website like background-color, custom text in wp-admin/customize.php.
I know I can add more options using customize_register , but the storefront theme has its own action hook for that, in fact I already added my own action hook to enable more options see below
as you can see the problem is that it creates another "footer" option, is there any way to overwrite or insert custom options, within the existing "footer" option of the parent theme?
here the code im using to insert options
function footer_customize_register( $custom_vars ) {
$custom_vars ->add_section(
'layout_section',
array(
'title' => __( 'Footer', 'pre' ),
'capability' => 'edit_theme_options',
'description' => __( 'Allows you to edit your theme layout.', 'pre' ),
'priority' => 25,
)
);
$custom_vars -> add_setting('pre_layout_options[address_text]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '000 7th St NW',
));
$custom_vars -> add_control('pre_layout_options[address_text]', array(
'label' => 'adress',
'section' => 'layout_section',
'type' => 'text',
));
$custom_vars -> add_setting('pre_layout_options[phone_text]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '01234-567',
));
$custom_vars -> add_control('pre_layout_options[phone_text]', array(
'label' => 'ZIP code',
'section' => 'layout_section',
'type' => 'text',
));
$custom_vars -> add_setting('pre_layout_options[VAT]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '00.000.000/0000-00',
));
$custom_vars -> add_control('pre_layout_options[VAT]', array(
'label' => 'VAT number',
'section' => 'layout_section',
'type' => 'text',
));
$custom_vars -> add_setting('pre_layout_options[Location]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => 'Centro',
));
$custom_vars -> add_control('pre_layout_options[Location]', array(
'label' => 'Location',
'section' => 'layout_section',
'type' => 'text',
));
}
add_action('customize_register', 'footer_customize_register');
the source code is from here
in section you need to add storefront_footer and add priority to change position. check below code.
function footer_customize_register( $custom_vars ) {
$custom_vars -> add_setting('pre_layout_options[address_text]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '000 7th St NW',
));
$custom_vars -> add_control('pre_layout_options[address_text]', array(
'label' => 'adress',
'section' => 'storefront_footer',
'type' => 'text',
'priority' => 50,
));
$custom_vars -> add_setting('pre_layout_options[phone_text]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '01234-567',
));
$custom_vars -> add_control('pre_layout_options[phone_text]', array(
'label' => 'ZIP code',
'section' => 'storefront_footer',
'type' => 'text',
'priority' => 60,
));
$custom_vars -> add_setting('pre_layout_options[VAT]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => '00.000.000/0000-00',
));
$custom_vars -> add_control('pre_layout_options[VAT]', array(
'label' => 'VAT number',
'section' => 'storefront_footer',
'type' => 'text',
'priority' => 70,
));
$custom_vars -> add_setting('pre_layout_options[Location]', array(
'capability' => 'edit_theme_options',
'type' => 'option',
'default' => 'Centro',
));
$custom_vars -> add_control('pre_layout_options[Location]', array(
'label' => 'Location',
'section' => 'storefront_footer',
'type' => 'text',
'priority' => 80,
));
}
add_action('customize_register', 'footer_customize_register');
Tested and works.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
i created a custom post type but i only get default support features like thumbnails, exerpt etc but what i want is to add all extra features of ceris theme in posts into my custom post type can you help me out?
$args = array(
'label' => __( 'directory', 'Ceris' ),
'description' => __( 'directory all posts', 'Ceris' ),
'labels' => $labels,
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'excerpt','thumbnail', 'comments', 'revisions', 'custom-fields','post-formats','page-attributes','bk_review_score' ),
// You can associate this CPT with a taxonomy or custom taxonomy.
'taxonomies' => array( 'posts' ),
/* 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' => 'post',
'show_in_rest' => true,
);
check my support array like i'm trying to add bk_review_system into my cpt
yes you can do it
try the following code, BK come with a filter to add widget and there configuration
function bk_child_register_meta_boxes($meta_boxes) {
$meta_boxes[] = array(
'id' => 'bk_review',
'title' => esc_html__( 'BK Review System', 'ceris' ),
'pages' => array( 'directory' ),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'type' => 'heading',
'name' => esc_html__('Author Review', 'ceris'),
'desc' => esc_html__('This section allow you to give your review, pros, cons', 'ceris'),
),
// Enable Review
array(
'name' => esc_html__( 'Review Box', 'ceris' ),
'id' => 'bk_review_checkbox',
'type' => 'checkbox',
'desc' => esc_html__( 'Enable Review On This Post', 'ceris' ),
'std' => 0,
),
array(
'visible' => array( 'bk_review_checkbox', '=', 1),
'type' => 'divider',
),
array(
'id' => 'bk_review_box_position',
'name' => esc_html__( 'Review Box Position', 'ceris' ),
'type' => 'select',
'options' => array(
'default' => esc_html__( 'Default -- Under the post content', 'ceris' ),
'top' => esc_html__( 'On top of the post content ', 'ceris' ),
),
// Select multiple values, optional. Default is false.
'multiple' => false,
'std' => 'default',
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'visible' => array( 'bk_review_checkbox', '=', 1),
'type' => 'divider',
),
array(
'name' => 'Product Image',
'id' => 'bk_review_product_img',
'type' => 'single_image',
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'name' => esc_html__( 'Product name', 'ceris' ),
'id' => 'bk_review_box_title',
'type' => 'textarea',
'cols' => 20,
'rows' => 2,
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'name' => esc_html__( 'Description', 'ceris' ),
'id' => 'bk_review_box_sub_title',
'type' => 'textarea',
'cols' => 20,
'rows' => 2,
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'visible' => array( 'bk_review_checkbox', '=', 1),
'type' => 'divider',
),
//Review Score
array(
'name' => esc_html__( 'Review Score', 'ceris' ),
'id' => 'bk_review_score',
'class' => 'ceris-',
'type' => 'slider',
'visible' => array( 'bk_review_checkbox', '=', 1),
'js_options' => array(
'min' => 0,
'max' => 10.05,
'step' => .1,
),
),
array(
'visible' => array( 'bk_review_checkbox', '=', 1),
'type' => 'divider',
),
// Summary
array(
'name' => esc_html__( 'Summary', 'ceris' ),
'id' => 'bk_review_summary',
'type' => 'textarea',
'cols' => 20,
'rows' => 4,
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'visible' => array( 'bk_review_checkbox', '=', 1),
'type' => 'divider',
),
//Pros & Cons
array(
'name' => esc_html__( 'Pros and Cons', 'ceris' ),
'id' => 'bk_pros_cons',
'type' => 'checkbox',
'desc' => esc_html__( 'Enable Pros and Cons On This Post', 'ceris' ),
'std' => 0,
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'visible' => array( 'bk_pros_cons', '=', 1),
'type' => 'divider',
),
array(
'name' => esc_html__( 'Pros Title', 'ceris' ),
'id' => 'bk_review_pros_title',
'type' => 'textarea',
'cols' => 20,
'rows' => 2,
'visible' => array( 'bk_pros_cons', '=', 1),
),
array(
'name' => esc_html__( 'Pros (Advantages)', 'ceris' ),
'id' => 'bk_review_pros',
'type' => 'textarea',
'cols' => 20,
'clone' => true,
'rows' => 2,
'visible' => array( 'bk_pros_cons', '=', 1),
),
array(
'visible' => array( 'bk_pros_cons', '=', 1),
'type' => 'divider',
),
array(
'name' => esc_html__( 'Cons Title', 'ceris' ),
'id' => 'bk_review_cons_title',
'type' => 'textarea',
'cols' => 20,
'rows' => 2,
'visible' => array( 'bk_pros_cons', '=', 1),
),
array(
'name' => esc_html__( 'Cons (Disadvantages)', 'ceris' ),
'id' => 'bk_review_cons',
'type' => 'textarea',
'cols' => 20,
'clone' => true,
'rows' => 2,
'visible' => array( 'bk_pros_cons', '=', 1),
),
array(
'type' => 'divider',
),
array(
'type' => 'heading',
'name' => esc_html__('Performance and User Review', 'ceris'),
'desc' => esc_html__('This section allow you to have some criterias and allow your reader to share their review', 'ceris'),
),
array(
'name' => esc_html__( 'Performance and User Review Check Box', 'ceris' ),
'id' => 'bk_performance_review_checkbox',
'type' => 'checkbox',
'desc' => esc_html__( 'Enable This Review', 'ceris' ),
'std' => 0,
),
array(
'visible' => array( 'bk_performance_review_checkbox', '=', 1),
'type' => 'divider',
),
array(
'id' => 'bk_performance_review_score_criteria_group',
// Group field
'type' => 'group',
// Clone whole group?
'clone' => true,
'visible' => array( 'bk_performance_review_checkbox', '=', 1),
// Sub-fields
'fields' => array(
array(
'name' => esc_html__( 'Criteria Title', 'ceris' ),
'id' => 'review_criteria_title',
'type' => 'text',
),
array(
'name' => esc_html__( 'Criteria Score', 'ceris' ),
'id' => 'review_criteria_score',
'class' => 'ceris-',
'type' => 'slider',
'js_options' => array(
'min' => 0,
'max' => 10.05,
'step' => .1,
),
),
),
),
array(
'type' => 'divider',
),
array(
'name' => esc_html__( 'Reader Review Form', 'ceris' ),
'id' => 'bk_reader_review_checkbox',
'visible' => array( 'bk_performance_review_checkbox', '=', 1),
'type' => 'checkbox',
'desc' => esc_html__( 'Enable Reader Review', 'ceris' ),
'std' => 0,
),
)
);
return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'bk_child_register_meta_boxes', 999,1 );
How do I get the settings to the frontend? I need to add classes to vc_row.
/**
* Ken Burns Effect for Row.
*/
add_action( 'vc_after_init', 'ken_burns_effect_add_option_to_vc_row' );
function ken_burns_effect_add_option_to_vc_row() {
// Ken Burns Effect Attributes
$ken_burns_effect_attributes =
array(
array(
'type' => 'checkbox',
'heading' => __( 'Ken Burns for image background', 'ken_burns_effect' ),
'param_name' => 'enable_ken_burns_effect',
'value' => array(
__( 'Yes', 'ken_burns_effect' ) => 'yes',
),
'description' => 'Check this box if you want to enable ken burns effect for this row.',
),
array(
'type' => 'dropdown',
'heading' => __( 'Direction', 'ken_burns_effect' ),
'param_name' => 'direction_ken_burns_effect',
'value' => array(
'Zoom In' => 'zoom_in',
'Zoom Out' => 'zoom_out',
),
'description' => __( '', 'ken_burns_effect' ),
'dependency' => array(
'element' => 'enable_ken_burns_effect',
'value' => array( 'yes' ),
),
),
array(
'type' => 'textfield',
'heading' => __( 'Transition speed', 'ken_burns_effect' ),
'param_name' => 'transition_speed_ken_burns_effect',
'value' => '',
'description' => __( '', 'ken_burns_effect' ),
'dependency' => array(
'element' => 'enable_ken_burns_effect',
'value' => array( 'yes' ),
),
),
);
vc_add_params( 'vc_row', $ken_burns_effect_attributes);
}
You will have to override the vc_row.php by copying it to your theme or plugin.
You can check their documentation on how to set the override directory: https://kb.wpbakery.com/docs/inner-api/vc_set_shortcodes_templates_dir/
Then you can use your custom params inside vc_row.php using their param_name eg:
$enable_ken_burns_effect;
$direction_ken_burns_effect;
$transition_speed_ken_burns_effect;
Keep in mind that you have to override vc_row_inner.php too if you want to use options there. Same goes for section and columns.
In my theme, I set up 2 options use Theme Customization API, the code snippet below.
I want to display the radio option when the checkbox is true, when the checkbox is false, the radio hidden. I try to use active_callbackļ¼but not working. So, How can achieve this function?
Thanks!
// Related Post.
$wp_customize->add_setting('_related_post', array(
'capability' => 'edit_theme_options',
'default' => 0,
'transport' => 'postMessage',
));
$wp_customize->add_control('_related_post', array(
'settings' => '_related_post',
'label' => __('Display Related Posts', 'typenow'),
'section' => '_theme_options',
'type' => 'checkbox',
'priority' => 30,
));
// Related Post Num.
$wp_customize->add_setting('_related_post_num', array(
'capability' => 'edit_theme_options',
'default' => '2',
'transport' => 'postMessage',
));
$wp_customize->add_control('_related_post_num', array(
'settings' => '_related_post_num',
'label' => __('Related Posts Number', 'typenow'),
'section' => '_theme_options',
'type' => 'radio',
'priority' => 35,
'choices' => array (
'2' => __('Two posts', 'typenow'),
'4' => __('Four posts', 'typenow'),
),
));
The solution:
$wp_customize->add_control('_related_post_num', array(
'settings' => '_related_post_num',
'label' => __('Related Posts Number', 'typenow'),
'section' => '_theme_options',
'type' => 'radio',
'priority' => 35,
'choices' => array (
'2' => __('Two posts', 'typenow'),
'4' => __('Four posts', 'typenow'),
),
'active_callback' => function(){
return get_theme_mod( '_related_post', false );
},
));