Home Forums General Issues Write an ACF Image to the WP Site Logo and Site Icon


Write an ACF Image to the WP Site Logo and Site Icon

  • I’m building a “site customizer” page with various site settings easily accessible and editable from a single area (also to be accessed by Editors, in addition to full admins)

    I’ve got simple text things such as the Site Tile, Tagline and even Timezone figured out by using update_options.

    // Update WP Site Options
    update_option('blogname', get_field('platform_title', 'options'), true); // Write custom Site Title
    update_option('blogdescription', get_field('platform_subtitle', 'options'), true); // Write custom site Sub-Title Tagline
    update_option('timezone_string',get_field('platform_timezone','options'), true); // Write custom timezone 
    update_option('custom_logo',get_field('platform_logo','options'), true); // Update Site Logo
    update_option('site_icon',get_field('platform_favicon','options'), true); // Update Site Favicon / Icon

    I know the “update_option” function written like above probably isn’t correct for images. I’m just not sure if/how to write an ACF image field into the WP Logo and Icon fields.

  • These options store ID values, you just need to get the ID value from the ACF field, this can be done by not getting the formatted value using false for the 3rd argument of get_field()

    update_option('custom_logo',get_field('platform_logo','options', false), true); // Update Site Logo
    update_option('site_icon',get_field('platform_favicon','options', false), true); // Update Site Favicon / Icon
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.