Last active
December 8, 2017 05:26
-
-
Save humayunahmed8/5a4a88d79a0e839bef7f1ee835ac193c to your computer and use it in GitHub Desktop.
Add WP Setting API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WP setting API (use for all section heading and short desription) | |
function wp_option_field(){ | |
//add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() ) | |
add_settings_field( 'service_title', 'Service Title', 'service_title_callback' , 'general' ); | |
add_settings_field( 'service_des', 'Service Descriptin', 'service_des_callback' , 'general' ); | |
add_settings_field( 'our_team_title', 'Team Title', 'our_team_title_callback' , 'general' ); | |
add_settings_field( 'our_team_des', 'Team Description', 'our_team_des_callback' , 'general' ); | |
add_settings_field( 'our_price_title', 'Pricing Title', 'our_price_title_callback' , 'general' ); | |
add_settings_field( 'our_price_des', 'Pricing Description', 'our_price_des_callback' , 'general' ); | |
//register_setting( string $option_group, string $option_name, array $args = array() ) | |
register_setting( 'general', 'service_title' ); | |
register_setting( 'general', 'service_des' ); | |
register_setting( 'general', 'our_team_title' ); | |
register_setting( 'general', 'our_team_des' ); | |
register_setting( 'general', 'our_price_title' ); | |
register_setting( 'general', 'our_price_des' ); | |
function service_title_callback(){ | |
//echo '<input type="text" name="service_title" value="'.get_option('service_title'). '"/>' ; | |
echo '<input type="text" name="service_title" value=" ' . get_option('service_title') .' "/>'; | |
} | |
function service_des_callback(){ | |
echo '<input type="text" name="service_des" value=" ' . get_option('service_des') .' "/>'; | |
} | |
function our_team_title_callback(){ | |
echo '<input type="text" name="our_team_title" value=" ' . get_option('our_team_title') .' "/>'; | |
} | |
function our_team_des_callback(){ | |
echo '<input type="text" name="our_team_des" value=" ' . get_option('our_team_des') .' "/>'; | |
} | |
function our_price_title_callback(){ | |
echo '<input type="text" name="our_price_title" value=" ' . get_option('our_price_title') .' "/>'; | |
} | |
function our_price_des_callback(){ | |
echo '<input type="text" name="our_price_des" value=" ' . get_option('our_price_des') .' "/>'; | |
} | |
} | |
add_action('admin_init' , 'wp_option_field'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage Example of Setting API | |
<div class="section-head"> | |
<h3 class="section-title"><?php echo get_option('our_price_title'); ?></h3> | |
<p class="section-description"><?php echo get_option('our_price_des'); ?></p> | |
</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment