- First of all, don’t ask opinion based questions on StackOverflow.
- Secondly, try Googling for an answer
You can try the WordPress Theme Customizer, check out the docs:
Here is what it looks like
Basically you need to register Sections (stores a set of options). Then you need to register Settings (to store the value of each option) and Controls (a form for users to change the options)
To start of, create a function and use the hook customize-register
function mytheme_customize_register( $wp_customize ) {
//All our sections, settings, and controls will be added here
}
add_action( 'customize_register', 'mytheme_customize_register' );
You can add a section like so:
$wp_customize->add_section( 'your_section_id' , array(
'title' => __( 'Visible Section Name', 'mytheme' ),
'priority' => 30, // To control the order it appears in
) );
You can add a setting like so:
$wp_customize->add_setting( 'your_setting_id' , array(
'default' => '#000000',
) );
And a control like so:
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array(
'label' => __( 'Header Color', 'mytheme' ),
'section' => 'your_section_id',
'settings' => 'your_setting_id',
) ) );
If you add the code for the sections, settings and controls inside your function, and put that inside your functions.php
file. Then, in wp-admin.php
, hover over Appearance and click Customize. Your section and control will be in there for you to change.
To get your setting, use the following code in your theme files:
<?php echo get_theme_mod('your_setting_id') ?>
This will echo the value of the setting.
Hope this helps!