Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm building a custom theme, along with a custom mobile theme counterpart. They don't share resources, CSS, etc. (cause I like to keep them clean, and separate).

My question is: how does everyone (preferably other professionals) go about doing this? I'm using the Mobile Detect script to redirect users to the 'mobile' sub-folder when they access the site via their mobile phone, etc. Is there another, more elegant way of doing this?

share|improve this question

2 Answers 2

Personally I always tend to stick to using responsive design rather than a completely different theme. You then will only have theme to keep updated.

Check out this article for more information

http://www.techrepublic.com/blog/webmaster/how-to-get-started-with-responsive-web-design/1769

share|improve this answer
    
True, I agree. However, sometimes I get put into places where I'm technically a "cog" in a machine. There's often some issues with creating a fully responsive design, sometimes it's simply not feasible in terms of cost, and other factors. –  willbeeler Nov 13 '12 at 18:24

Will,

You can use the template include filter to redirect visitors to a different page template conditionally.

Example code to redirect a custom post type template:

add_filter('template_include', 'get_customer_review_cpt_template', 100);

function get_customer_review_cpt_template($template){
global $template;

    // Our custom post type.
$post_type   = 'customer_reviews';
$post_object = $GLOBALS['post'];

if ( !isset( $post_object->post_type ) ) {
    return $template;
}
    // Send our plugin file.
if ( is_singular() && $post_object->post_type === $post_type ) {
    return dirname(__FILE__) . "/views/single-$post_type.php";
}
return $template;
 }

Additionally, you can also use the add_filter('template','get_your_new_theme'); to conditionally direct visitors to a different theme if they are on a mobile device. You are a little limited with what you can do here, but I have found it useful for some mobile sites.

Here is some code I used as a plugin to direct mobile visitors to a different theme: https://gist.github.com/3454745

share|improve this answer
3  
I should add that if possible, you should keep it simple and just use CSS media queries whenever possible. It will keep your code cleaner, and CSS media queries do not rely on detecting specified browser agents like the PHP solutions. –  Rachel Baker Nov 13 '12 at 14:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.