Articles of switch theme

Switching Theme and back will reset the previous Theme's settings?

Everyone, I have a WordPress site on my hands, and I wanted to try a new Theme; I changed the active one and, unsatisfied, I selected again the previous one… and I found the website’s appearance to be changed. Is there a safe way to restore the site’s appearance or are the settings lost and […]

Can I easily switch themes on a fully built website?

I have a WordPress website for a while now but I wanted to give it a more professional and clean look so I bought the porto theme to make that happen. The problem is that since the website was already completely built, the theme switch kind off messed things up a lot. I expected this […]

Translate a site based on different themes

This is my first question on the site. First of all I want to apologize for my bad English. I´m migrating a site to a WordPress theme, and I need a solution to translate the theme to 3 different languages. I have the post translation on several custom post meta (title in Russian, title in […]

Change site template from php

What is the argument to pass to switch theme, when I have the result of wp_get_themes()? $args = array( ‘allowed’ => true ); $themes = wp_get_themes( ); foreach ($themes as $theme) { $argument_to_pass_to_switch_theme = ?????? }

How to optimize on-the-fly theme switching for mobile browsers?

I’m using switch_theme() to switch between default and mobile themes for my visitors in real time. Here’s my code : // Get the user agent $user_agent = $_SERVER[‘HTTP_USER_AGENT’]; // Preg match for mobile browsers (courtesy : $preg_match = preg_match( ‘/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i’,$user_agent) || preg_match(‘/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt […]

How to switch theme if the current user is admin?

I am trying to switch my current custom theme to twenty fifteen theme if the visitor is admin. So I put following code into my custom theme functions.php /*** Switching theme to Admin ***/ add_action( ‘setup_theme’, ‘switch_user_theme’ ); function switch_user_theme() { if ( current_user_can( ‘manage_options’ ) ) { $user_theme = ‘Twenty Fifteen’; add_filter( ‘template’, create_function( […]

Switching content between summer and winter

I have been trying to come up with a good way to switch between summer and winter content. I am building a rental site and when the customer books they are automatically redirected to a second page with options to add other products to the cart. I want to have two buttons probably at the […]

How to display message (with switch_theme hook) after deactivating My theme?

I’m able to display a message by activation of my theme with the ‘new’ after_switch_theme hook this way: function themeActivationFunction($oldname, $oldtheme=false) { $msg = ‘ <div class=”error”> <p>The ‘ . get_option( ‘current_theme’ ) . ‘ theme has been ACTIVATED.</p> </div>’; add_action( ‘admin_notices’, $c = create_function( ”, ‘echo “‘ . addcslashes( $msg, ‘”‘ ) . ‘”;’ […]

How to load a different theme for categories?

I need to load a completely different theme for my categories. My search came up with switch_theme function but it changes the theme permanently while I only need the theme change only occur on my category pages. Then I found this. add_filter( ‘template’, ‘my_change_theme’ ); add_filter( ‘option_template’, ‘my_change_theme’ ); add_filter( ‘option_stylesheet’, ‘my_change_theme’ ); function my_change_theme($theme) […]

Styleswitcher or themeswitcher to allow user to switch back to standard view from mobile device

I created a mobile version of my site with CSS, with all my styles in a single stylesheet (using @media only screen and (max-width: 480px), only screen and (max-device-width: 480px) to define mobile styles). When it’s all in a single stylesheet, it works fine. But I want to allow users to switch back to standard […]