Update wordpress blogname and blogdescription using Redux

Is it possible to update wordpress blogname and blogdescription via Redux framework.

array(
    'id'        => 'blogdescription',
    'type'      => 'text',
    'title'     => 'Blog Description',
    'default'   => '',
),

Related posts

2 comments

  1. You can use update_option(); function

    update_option( 'blogname', 'New Value' );

    update_option( 'blogdescription', 'New Value' );

    Hooking on Admin

    add_action('admin_init', 'update_my_site_blog_info');
    function update_my_site_blog_info() {
        $old  = get_option('blogdescription');
        $new = 'New Site Title';
        if ( $old  !== $new ) {
            update_option( 'blogdescription', $new  );
        }
    }
    

    EDIT:

    I guess its better this way,

    add_filter('redux/options/[your_opt_name]/compiler', 'update_my_site_blog_info');
    function update_my_site_blog_info() {
        $new = 'New Site Title';
        update_option( 'blogdescription', $new  );
    }
    

    then your field needs to enabled compiler

    array(
        'id'        => 'blogdescription',
        'type'      => 'text',
        'title'     => 'Blog Description',
        'default'   => '',
        'compiler'  => true,
    ),
    
  2. Thanks for the help, i did like this to make it work.

    add_action('init', 'update_my_site_blog_info');
        function update_my_site_blog_info()
        {
            global $opt_keyname;
            $check = array('blogdescription', 'blogname');
            foreach($check as $key)
            {
                if ( get_option($key)  != $opt_keyname[$key] )
                {
                    update_option( $key, $opt_keyname[$key] );
                }
            }
        }
    
    
    Redux::setSection( $opt_name,
            array(
                'title'     => 'Basic Settings',
                'id'        => 'basic_settings',
                'fields'    => array(
                    array(
                        'id'        => 'blogname',
                        'type'      => 'text',
                        'title'     => 'Blog Title',
                        'default'   => get_option( 'blogname' )
                    ),
                    array(
                        'id'        => 'blogdescription',
                        'type'      => 'text',
                        'title'     => 'Blog Description',
                        'default'   => get_option( 'blogdescription' )
                    ),
                )
            )
        );
    

Comments are closed.