Support

Account

Home Forums Add-ons Options Page Override core WP settings via ACF options page? Reply To: Override core WP settings via ACF options page?

  • I can’t give you details on every possible WP option, but generally you’re got 2 choices.

    1) Use an acf/save_post filter when the options page is saved, take the values from the ACF fields and update the WP option value. Exactly how you’d do this update would likely be different depending on the option you’re overwriting. For example, the “Blog Title” field in the options table as “blogname”.

    
    update_option('blogname', get_field('my_blog_name_field', 'options'), true);
    

    2) The second option is to override the WP options in code. For example

    
    add_filter('option_blogname', 'my_override_blog_name', 10, 2);
    function my_override_blog_name($value, $option) {
      $value = get_field('my_blog_name_field', 'options');
      return $value;
    }
    

    Like I said, the above is only one example. You’d have to investigate how/where each of the options you want to override is saved and what can be done to override them. More than likely I would go with the first option of updating the actual WP options when the options page is saved. The reason for this is that 1) the DB locations of these options is not likely to ever change (while the filters for overriding them after the fact might) and 2) using the first method will work for the front end of the site even if ACF is deactivated.