Home Wordpress Hooks How to add more panel or section into your Wordpress customizer?

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

by therichpost
0 comment
How to add custom meta title and meta description in Wordpress?

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

You may also like

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.