[wp-hackers] changing a theme via wpdb class

Christopher Ross cross at thisismyurl.com
Sun Apr 29 19:22:09 UTC 2012


if you're going to do this for whatever reason, consider adding it to the theme_redirect instead of the init and also including a wrapper around it and use the switch_theme() instead.

add_action( 'template_redirect' , 'change_theme_manually' );
function change_theme_maually() {

    if ( 'twentyeleven' != get_current_theme() )
         switch_theme( 'twentyeleven' );

}

I've not tested that, but it should work.

c.

On 2012-04-29, at 2:59 PM, Chris McCoy wrote:

> function change_theme_manually() {
>        global $wpdb;
>        $newtheme = 'twentyeleven';
>        $wpdb->update($wpdb->options,
>                array('template'=> $newtheme),
>                array('stylesheet'=> $newtheme),
>                array('current_theme' => $newtheme)
>        );
> }
> 
> 
> add_action('init','change_theme_manually');
> 
> can someone tell me what is wrong with this?
> 
> Doesn't seem to update the options
> 
> 
> 
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers




--
Christopher Ross
cross at thisismyurl.com
http://thisismyurl.com

http://facebook.com/christopher.f.ross/
http://twitter.com/thisismyurl/
http://pinterest.com/thisismyurl/



More information about the wp-hackers mailing list