advanced custom fields – How do I change the site title and tagline in an ACF options page?
Question
Use the Code Snippets plugin to add:
function update_site_settings() {
$screen = get_current_screen();
if (strpos($screen->id, 'your-options-page-slug-here') == true) {
$blogname = sanitize_text_field(get_field('your_site_title_field_name_here', 'options'));
update_option('blogname', $blogname);
$blogdescription = sanitize_text_field(get_field('your_site_tagline_field_name_here', 'options'));
update_option('blogdescription', $blogdescription);
}
}
add_action('acf/save_post', 'update_site_settings', 20);
What’s not covered is keeping the General Settings WordPress option page fields in sync with the ACF fields. If you’re creating a simplified UI for a client or end-user, you might want to consider hiding the Settings option page in the menu.
0
3 months
2022-05-18T14:35:31-05:00
2022-05-18T14:35:31-05:00 0 Answers
0 views
0
Leave an answer