问题场景
在PC端打开新窗口体验还是不错的,但是到移动端打开新窗口就会出现下面的场景
就看了会儿网站打开一堆页面,这样体验是很差的
如何让PC打开文章进新的窗口,移动端在原页面打开文章?
![图片[1]-子比主题优化新窗口打开相关问题-FancyPig's blog](https://static.iculture.cc/wp-content/uploads/2022/04/20220423080643626.png?x-oss-process=image/auto-orient,1/format,webp/watermark,image_cHVibGljL2xvZ28ucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2UvcmVzaXplLFBfMTA,x_10,y_10)
解决方案
我们可以只让PC端打开文章打开新窗口,移动端不受影响,只需要增加一个判断
wp-content/themes/zibll/inc/functions/zib-theme.php第753行
//文章列表新窗口打开
function _post_target_blank()
{
return _pz('target_blank') ? ' target="_blank"' : '';
}
修改为
//文章列表新窗口打开
function _post_target_blank()
{
if (!wp_is_mobile()) {
return _pz('target_blank') ? ' target="_blank"' : '';
}
}
然后,在后台文章&列表>新窗口打开文章
![图片[2]-子比主题优化新窗口打开相关问题-FancyPig's blog](https://static.iculture.cc/wp-content/uploads/2022/04/20220423080654343.png?x-oss-process=image/auto-orient,1/format,webp/watermark,image_cHVibGljL2xvZ28ucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2UvcmVzaXplLFBfMTA,x_10,y_10)
拓展:帖子、版块也可以这么做
首先需要开启相应功能
- 社区&论坛>全局设置>版块新窗口打开
- 社区&论坛>全局设置>帖子新窗口打开
![图片[3]-子比主题优化新窗口打开相关问题-FancyPig's blog](https://static.iculture.cc/wp-content/uploads/2022/04/20220423080707715.png?x-oss-process=image/auto-orient,1/format,webp/watermark,image_cHVibGljL2xvZ28ucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2UvcmVzaXplLFBfMTA,x_10,y_10)
针对版块,手机不打开新窗口的修改方法
则需修改/wp-content/themes/zibll/inc/functions/bbs/inc/plate.php第551行
$target_blank = _pz('plate_target_blank') ? ' target="_blank"' : '';
修改为
if (!wp_is_mobile()) {
$target_blank = _pz('plate_target_blank') ? ' target="_blank"' : '';
}
第553行
$target_blank = _pz('plate_target_blank') ? ' target="_blank"' : '';
修改为
if (!wp_is_mobile()) {
$target_blank = _pz('plate_target_blank') ? ' target="_blank"' : '';
}
针对帖子,手机不打开新窗口的修改方法
/wp-content/themes/zibll/inc/functions/bbs/inc/posts.php第588行
$target_blank = _pz('posts_target_blank') && $post_status !== 'trash' ? ' target="_blank"' : '';
修改为
if (!wp_is_mobile()) {
$target_blank = _pz('posts_target_blank') && $post_status !== 'trash' ? ' target="_blank"' : '';
}
第1137行
$target_blank = _pz('posts_target_blank') && $post_status !== 'trash' ? ' target="_blank"' : '';
修改为
if (!wp_is_mobile()) {
$target_blank = _pz('posts_target_blank') && $post_status !== 'trash' ? ' target="_blank"' : '';
}
© 版权声明
THE END
- 最新
- 最热
只看作者