我需要隐藏我博客的品牌部分,但只有当有人在iPad上查看时。我不知道如何攻击这一点。
编辑:功能remove_access
目前可以在我的模板中使用,但我需要添加iPad功能。
因此,这对于试图隐藏该区域是否正确:
<?php
function remove_access() {
if(is_page(array(63, 386, 391, 405, \'forums\'))) {
remove_action(\'thematic_header\',\'thematic_blogtitle\',3);
remove_action(\'thematic_header\', \'thematic_blogdescription\',5);
remove_action(\'thematic_header\', \'thematic_brandingclosing\',7);
remove_action(\'thematic_header\',\'thematic_access\',9);
remove_action(\'thematic_footer\',\'thematic_siteinfoopen\',20);
remove_action(\'thematic_footer\',\'thematic_siteinfo\',30);
}
}
if( preg_match(\'/ipad/i\',$_SERVER[\'HTTP_USER_AGENT\']) ){
add_action(\'template_redirect\', \'remove_access\');
}
编辑-3:
完整功能
将条件更改为:如果(它是iPad,页面是博客)或(如果它是数组中的一个页面),则删除项目。
<?php
function remove_access() {
if( preg_match(\'/ipad/i\',$_SERVER[\'HTTP_USER_AGENT\']) && is_page(\'blog\') || is_page(array(63, 386, 391, 405, \'forums\')) ){
remove_action(\'thematic_header\',\'thematic_blogtitle\',3);
remove_action(\'thematic_header\', \'thematic_blogdescription\',5);
remove_action(\'thematic_header\', \'thematic_brandingclosing\',7);
remove_action(\'thematic_header\',\'thematic_access\',9);
remove_action(\'thematic_footer\',\'thematic_siteinfoopen\',20);
remove_action(\'thematic_footer\',\'thematic_siteinfo\',30);
}
}
add_action(\'template_redirect\', \'remove_access\');
编辑-4:
添加一个从子页面删除的函数。我试过这个,但似乎不起作用:
function remove_access() {
if( preg_match(\'/ipad/i\',$_SERVER[\'HTTP_USER_AGENT\']) && is_page(\'blog\') && ($post->post_parent == \'blog\') || is_page(array(63, 386, 391, 405, \'forums\')) && ($post->post_parent == (63, 386, 391, 405, \'forums\')) ){
remove_action(\'thematic_header\',\'thematic_blogtitle\',3);
remove_action(\'thematic_header\', \'thematic_blogdescription\',5);
remove_action(\'thematic_header\', \'thematic_brandingclosing\',7);
remove_action(\'thematic_header\',\'thematic_access\',9);
remove_action(\'thematic_footer\',\'thematic_siteinfoopen\',20);
remove_action(\'thematic_footer\',\'thematic_siteinfo\',30);
}
}
add_action(\'template_redirect\', \'remove_access\');