Wordpress HooksWordpress Tricks

How to add more panel or section into your WordPress customizer?

add more panel or section into your Wordpress customizer

wordpress
249Views

Hello, welcome to therichpost.com. In this post, I will tell you How to add more panel or section into your WordPress customizer? WordPress is the best cms. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress.

WordPress give customizer options to make dynamic content add and edit easily for anyone and here is working example of it.

Here is code add more panel or section into your WordPress customizer and you need to add this code into your theme’s functions.php file:
function my_customize_register( $wp_customize ) {
$wp_customize->add_control(
        'footercopyrighttxt',
        array(
            'label'      => 'Footer Copyright Text',
            'section'    => 'theme_setting',
            'settings'   => 'footercopyright',
            'type'		 => 'textarea'
        )
);
$wp_customize->add_control(
       new WP_Customize_Image_Control(
           $wp_customize,
           'logoimg',
           array(
               'label'      => __( 'Upload a logo', 'els' ),
               'section'    => 'theme_setting',
               'settings'   => 'logoimage'
           )
       )
   );
}
}
add_action( 'customize_register' , 'my_customize_register' );

 After added above code, you can new sections into your wordpress customize section( Footer Copyright text and Upload A logo) and for get all values you need to add below code into your theme’s php template file:

<span><?php echo get_option('footercopyright'); ?></span>

<?php if(get_option('logoimage') != ""){ ?>
               <a href="<?php echo site_url(); ?>">
                <img src="<?php echo get_option('logoimage'); ?>" alt="#"/>
              </a>
              <?php } ?>

 That is it.

There are so many tricks in wordpress and I will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

Positive SSL