WordPress: Tinye profaịlụ mgbasa ozi ọha na isiokwu WordPress gị
WordPress na-enye profaịlụ onye ọrụ na ntọala maka njikọ mmekọrịta; Otú ọ dị, saịtị ndị ọzọ na-elekọta mmadụ na-enye ohere maka saịtị ma ọ bụ blọgụ gị dum iji nwee ọnụnọ n'ime netwọk ndị ahụ. Anyị na-arụ ọrụ na saịtị ndị ahịa n'izu a ebe anyị chọrọ ime ka ọ dịrị ha mfe ịtọ na ịgbakwunye njikọ mmekọrịta saịtị ha, yabụ anyị gbakwunyere nhọrọ ndị ọzọ na ha. Ntọala Nzuzo General WordPress page.
Nzọụkwụ mbụ anyị bụ imelite Ọrụ Isiokwu ha (functions.php) na isiokwu nwata ha wee debanye aha ntọala nke ọ bụla anyị chọrọ ịgbakwunye:
// —————Add Settings to General Settings—————–
function social_settings_api_init() {
// Add the section to general settings so we can add our
// fields to it
add_settings_section('social_setting_section',
'Social sites on the web',
'social_setting_section_callback_function',
'general');
// Add the field with the names and function to use for our new
// settings, put it in our new section
add_settings_field('general_setting_facebook',
'Facebook Page',
'general_setting_facebook_callback_function',
'general',
'social_setting_section');
// Register our setting so that $_POST handling is done for us and
// our callback function just has to echo the <input>
register_setting('general','general_setting_facebook');
add_settings_field('general_setting_twitter',
'Twitter Account',
'general_setting_twitter_callback_function',
'general',
'social_setting_section');
register_setting('general','general_setting_twitter');
add_settings_field('general_setting_youtube',
'YouTube Page',
'general_setting_youtube_callback_function',
'general',
'social_setting_section');
register_setting('general','general_setting_youtube');
add_settings_field('general_setting_linkedin',
'LinkedIn Page',
'general_setting_linkedin_callback_function',
'general',
'social_setting_section');
register_setting('general','general_setting_linkedin');
}
add_action('admin_init', 'social_settings_api_init');
Nzọụkwụ anyị ọzọ bụ ịgbakwunye ogige ndị dị n'ime peeji nke Ntọala General nke ga-echekwa ozi ahụ n'ime ha:
// —————-Settings section callback function———————-
function social_setting_section_callback_function() {
echo '<p>This section is where you can save the social sites where readers can find you on the Internet.</p>';
}
function general_setting_facebook_callback_function() {
echo '<input name="general_setting_facebook" id="general_setting_facebook" type="text" value="'. get_option('general_setting_facebook') .'" />';
}
function general_setting_twitter_callback_function() {
echo '<input name="general_setting_twitter" id="general_setting_twitter" type="text" value="'. get_option('general_setting_twitter') .'" />';
}
function general_setting_youtube_callback_function() {
echo '<input name="general_setting_youtube" id="general_setting_youtube" type="text" value="'. get_option('general_setting_youtube') .'" />';
}
function general_setting_linkedin_callback_function() {
echo '<input name="general_setting_linkedin" id="general_setting_linkedin" type="text" value="'. get_option('general_setting_linkedin') .'" />';
}
Ugbu a, oge ọ bụla onye ahịa chọrọ imelite ntọala ibe ibe ha, ha nwere ike imelite mpaghara ntọala n'ime ha Ntọala Nzuzo General WordPress. N'ime isiokwu ahụ, anyị na-echeta naanị ntọala ebe ọ bụla achọrọ (n'ihe banyere onye ahịa a, ọ bụ ihe nchọgharị mgbasa ozi na-elekọta mmadụ na isi saịtị ha):
<?php echo get_option('general_setting_facebook'); >