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.

My site has a left side bar where I display categories and ads and what not. We are creating a basic android app for it and we are trying to figure out how to load the site on the app without sidebars. I know that I can disable the side bars in the options of WP but I don't want to disable them because I want people to be able to see the sidebar when they visit the site. Is there a trick to just loading the site without including the side bar? I just want to target the middle frame of the site. Any help would be appreciated.

site: tablified.com

share|improve this question
    
Remove the_sidebar() in your template file conditionally, probably based on the User-Agent header fingerprint retrieved by $_SERVER['HTTP_USER_AGENT']. –  soulseekah Oct 17 '11 at 4:14
    
Note the question tag. If this is a wordpress.com site, the OP won't have the option to modify template files. –  Chip Bennett Oct 17 '11 at 16:07
add comment

1 Answer

Do you have access to the theme files? If so, try replacing <?php get_sidebar() ?>; with this:

<?php
if( stristr($_SERVER['HTTP_USER_AGENT'],'android') === FALSE ) {
    get_sidebar();
}
?>

Otherwise, what about access to the theme's javascript file?

var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1;
if(isAndroid) {
    // Do something!
    // Perhaps target the CSS to hide the sidebar (display:none;)?
}

EDIT:

You can also try loading a stylesheet after the default one that targets mobile devices. Use the media attribute when loading the stylesheet:

<link href="mobile.css" rel="stylesheet" type="text/css" media="only screen and (max-device-width: 480px)" />

Alternatively you can just add some declarations into your existing stylesheet:

// target small screens (mobile devices or small desktop windows)  
@media only screen and (max-width: 480px) {  
    /* CSS goes here */  
}
share|improve this answer
    
Note the question tag. If this is a wordpress.com site, the OP won't have the option to modify template files. –  Chip Bennett Oct 17 '11 at 16:07
    
Sorry it was a mistake, I do have a dedicated hosted WP. I can access the theme files. tried searching for this <?php get_sidebar() ?>; and I could not find it anywhere. Its most likely due to the fact that I have a custom theme. Is there some place that I can place it to overwrite all other commands? like in the style.css? –  Ayman Oct 18 '11 at 6:49
1  
From a quick look at your site, this is not a matter of simply hiding the sidebar. You will have to make some significant changes to the CSS. I suggest you do one of two things: 1. make use of @media in your stylesheet to target mobile devices, OR, 2. Search for id="sidebar" in your theme files and include the if( stristr($_SERVER['HTTP_USER_AGENT'],'android') === FALSE ){} to determine whether the sidebar is shown or not. I would also use this method to conditionally load a secondary stylesheet android.css that adjusts the theme accordingly. –  Paul Oct 18 '11 at 8:04
    
Look here for more information on targeting specific mobile devices using CSS media queries. –  Paul Oct 18 '11 at 8:13
add comment

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.