Doesn’t working in Archive Pages: Shop, Blog
-
Hi,
I’m using CMB2 to enable custom Headers / Footers for specific pages on my theme, it’s working fine on normal pages. But it doesn’t work on Archive Pages, such as: Shop or Blog pages while it gets default header / footer via Customizer
<?php if (!defined( 'ABSPATH' )){ exit; } class OSF_Metabox { public function __construct() { add_action( 'cmb2_admin_init', array( $this, 'page_meta_box' ) ); } public function page_meta_box() { $prefix = 'osf_'; if(apply_filters('osf_check_page_settings', true)){ $this->page_header( $prefix ); $this->page_footer( $prefix ); } } private function page_footer($prefix = 'osf_') { $cmb2 = new_cmb2_box( array( 'id' => 'osf_page_footer', 'title' => __( 'Footer', 'poeme-core' ), 'object_types' => array( 'page' ), // Post type 'context' => 'normal', 'priority' => 'high', 'show_names' => true, ) ); $cmb2->add_field( array( 'name' => __( 'Enable Custom Footer', 'poeme-core' ), 'id' => $prefix . 'enable_custom_footer', 'type' => 'opal_switch', 'default' => '0', 'show_fields' => array( $prefix . 'footer_padding_top', $prefix . 'footer_layout', ), ) ); $cmb2->add_field( array( 'name' => __( 'Padding Top', 'poeme-core' ), 'id' => $prefix . 'footer_padding_top', 'type' => 'opal_slider', 'default' => '15', 'attrs' => array( 'min' => '0', 'max' => '100', 'step' => '1', 'unit' => 'px', ), ) ); $cmb2->add_field( array( 'name' => __( 'Layout', 'poeme-core' ), 'id' => $prefix . 'footer_layout', 'type' => 'opal_footer_layout', 'default' => '', ) ); $cmb2->add_field( array( 'name' => __( 'Enable Fixed Footer', 'poeme-core' ), 'id' => $prefix . 'enable_fixed_footer', 'type' => 'opal_switch', 'default' => '0' ) ); } private function page_header($prefix = 'osf_') { $cmb2 = new_cmb2_box( array( 'id' => 'osf_page_header', 'title' => __( 'Header', 'poeme-core' ), 'object_types' => array( 'page' ), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, ) ); $cmb2->add_field( array( 'name' => __( 'Enable Custom Header', 'poeme-core' ), 'id' => $prefix . 'enable_custom_header', 'type' => 'opal_switch', 'default' => '0', 'show_fields' => array( $prefix . 'header_layout', ), ) ); $headers = wp_parse_args( $this->get_post_type_data( 'header' ), array( 'default' => esc_html__( 'Default', 'poeme-core' ), ) ); $cmb2->add_field( array( 'name' => __( 'Layout', 'poeme-core' ), 'id' => $prefix . 'header_layout', 'type' => 'select', 'show_option_none' => false, 'default' => 'default', 'options' => $headers, ) ); } }
Regards,
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Doesn’t working in Archive Pages: Shop, Blog’ is closed to new replies.