您需要检查客户端发送的头,例如USER\\u AGENT
<?php
$iphone = strpos($_SERVER[\'HTTP_USER_AGENT\'],"iPhone");
$android = strpos($_SERVER[\'HTTP_USER_AGENT\'],"Android");
$palmpre = strpos($_SERVER[\'HTTP_USER_AGENT\'],"webOS");
$berry = strpos($_SERVER[\'HTTP_USER_AGENT\'],"BlackBerry");
$ipod = strpos($_SERVER[\'HTTP_USER_AGENT\'],"iPod");
$mobile = false;
if ($iphone || $android || $palmpre || $ipod || $berry == true)
{
$mobile = true;
}
?>
然后只需在IF条件中添加$mobile,如
<?php if ( is_active_sidebar( \'sidebar-1\' ) && $mobile == false) : ?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( \'sidebar-1\' ); ?>
</div><!-- #secondary .widget-area -->
<?php endif; ?>
希望这有帮助