change template with button

Try using switch_theme(). <?php switch_theme( $stylesheet ) ?> I have personally never used it but it sounds like what you want. You just need to pass the stylesheet name you are using. Here is a very basic demo I put together. You would basically but the following code, where ever its needed in both themes. … Read more

Switch-Case and user_role

You missed break statement This is how switch case works switch ($i) { case “apple”: echo “i is apple”; break; case “bar”: echo “i is bar”; break; case “cake”: echo “i is cake”; break; }

How to batch convert comments to posts?

You can copy this code into a plugin and when activated will convert all comments into posts, and delete the comments (so you will not have duplicates) You can also limit what kind of comments will be converted the posts using the parameters for get_comments ( http://codex.wordpress.org/Function_Reference/get_comments ) register_activation_hook( __FILE__, ‘wpse_29474_convert_to_posts’ ); function wpse_29474_convert_to_posts(){ $comments … Read more

Change header based on visitor choice

I would approach this by setting sessions. So when the user makes a selection set a session which contains the users choice. Then in wp_head write an if statement that pulls the relevant template dependant upon the value of the session.

How to switch subdomain with root domain and redirect traffic?

You can redirect all old inner pages to the new ones using .htaccess with HTTP header 301, but remember not to duplicate on the new site these parts of old URLs which goes after the old domain name (like /new-page-1/ in the example below). RewriteEngine On Redirect 301 /old-page-1/ httр://sub.domain.tld/new-page-1/ Redirect 301 /old-page-2/ httр://sub.domain.tld/new-page-2/ You … Read more

Subcategory IDs in relation to parent category ID switch case

Ok. This code: $cat_id_gum=””; if(($category[0]->parent)!=’0′) { $cat_id_gum=$category[0]->cat_ID; } elseif(($category[1]->parent)!=’0′) { $cat_id_gum=$category[1]->cat_ID; } elseif(($category[2]->parent)!=’0′) { $cat_id_gum=$category[2]->cat_ID; } else { $cat_id_gum=$category[3]->cat_ID; } Is not really necessary. I’ll show you what I mean in a bit. Later, however, you then set $cat_id_gum to the current post ID… $cat_id_gum = get_the_ID(); … which doesn’t make any sense and makes … Read more

Best Method to Switch Between Terms (Custom Taxonomy)

If I am reading your code and description correctly, you can simplify that to: $taxonomy = ‘delivery_option’; $do = get_the_terms($post->ID,$taxonomy); if (!empty($do) && !is_wp_error($do)) { $do = array_shift($do); // assuming a single value as per the description. $term = str_replace(‘-delivery’,”,$do->slug); get_template_part(‘includes/sidebar-part’,$term); } else { echo ‘<p>No custom include!</p>’; } Note, I used WordPress’s get_template_part() instead … Read more