Tuesday 29 April 2014

Plugin To Switch Themes Conditionally

WordPress already includes a function which enables you to switch themes:
<?php fb_widget( $stylesheet ) ?>
The only problem is, this function will write to your database.
If you need to change themes conditionally, another solution is to use the stylesheet & template filters in WordPress which you can add to a simple plugin like this.

<?php
/**
 * Plugin Name: FB Widget
 * Plugin URI:  http://wordpress.org/plugins/fb-widget
* Description: Description Goes here….
* Version:     1.0
 * Author:      Geeta Dhamija
 * @copyright 2014 DYC
 * Author URI:  http://dreamyourcareer.com/author/geeta-dyc/
 */

add_filter( 'stylesheet', 'wpsites_change_themes' );
add_filter( 'template',   'wpsites_change_themes' );
function wpsites_change_themes( $theme ) {
    if ( ! is_user_logged_in() )
        $theme = 'twentyfourteen';
    return $theme;
}
The above example will display the Twenty Fourteen parent theme to all logged out users and display whatever theme you have activated in the backend to all logged in users.

How To Use This Code

You’ll need to create a plugin with this code then install and activate it.
  1. Create a new file named plugin.php using a code editor like Notepad++ and copy the PHP code from the view raw link in the Gist labelled plugin.php.
  2. For the readme.txt file you can simply use notepad to create a new file named readme.txt and paste the text into the new file.

Then all you need to do is place both files in a new folder and send it to zip so you can upload, install & activate the plugin.

Thursday 24 April 2014

5 Things to Consider Before Designing New Website

Do you have the time to do a big bug hunt?

A bug hunt is imperative when creating a new website design because your website is going to be loaded with bugs. It is the same with any new piece of programming. You cannot be sure what parts will work correctly until it is up and running, and even then there are problems with compatibility or problems getting something to work on one platform as well as it work on another.

Is it time your website had a responsive design?

There is no law saying that you have to have a responsive website, but if you are looking into getting one then you should know that converting a website into a responsive website is a lot harder than building one from scratch. If you are going to have a responsive website, then you may as well couple it with a brand new website design.

Is the current design stale and old fashioned?

Websites and their designs may go out of fashion and if a website starts to look old then it is often considered to be cheap and therefore untrustworthy. If your website is becoming stale or old fashioned then it may be time for a redesign.

Will your current web content lend itself well to your new design?

The type of content and its amount is going to have to be placed onto your new web design. Is it going to be possible for your current website content to fit into your new design, both on an aesthetic level and on a technical level? Obviously if you are faced with this problem, then you could just change your new design to make it more suitable.

Will a new design cure some of your browser or device compatibility problems?


If you are already having browser or device compatibility problems, then a new design may help you to overcome them. That is going to help you quite a bit and so is a great reason to go for a new website design. You can test each design on numerous browsers, operating systems and devices before you upload it as your new website design.