Branchy主题HTML横幅配置 实现分类页同窗口跳转而非新标签打开
Branchy 1.0主题横幅短代码跳转逻辑调整方案
针对tm_banner短代码配置的横幅默认新标签页打开的问题,直接通过短代码原生参数调整即可实现当前标签页跳转,无需修改主题核心文件、额外引入自定义JS/CSS。
调整核心逻辑
Branchy主题的tm_banner短代码未传target参数时,会自动套用target="_blank"的新标签打开规则。只需给每一个tm_banner标签显式补充target="_self"参数,即可覆盖默认逻辑,实现当前页加载跳转。
具体调整操作
- 逐个给三个tm_banner子标签补充
target="_self"参数,替换原有空值/缺失的target配置 - 修正原短代码中的笔误:第三个gamers分类的链接原本多写了一段域名后缀(
my-domain.com.com),需修正为正确的站点域名
调整后的完整可用短代码
[container overflow="visible"][one_third margin="25px 0 0" content_width="96%"][tm_banner backgroung_img="https://my-domain.com/wp-content/uploads/2021/01/NOTEBOOK-verde.png" target="_self" link_url="https://my-domain.com/product-category/notebook/"][/tm_banner][/one_third][one_third margin="25px 10px 0" content_width="96%"][tm_banner backgroung_img="https://my-domain.com/wp-content/uploads/2021/01/banner-celular-verde.png" target="_self" link_url="https://my-domain.com/product-category/celulares/"][/tm_banner][/one_third][one_third margin="25px 0 0 20px" content_width="96%" classname="home_banner_3"][tm_banner backgroung_img="https://my-domain.com/wp-content/uploads/2021/01/gammers-verde.png" target="_self" link_url="https://my-domain.com/product-category/gamers/"][/tm_banner][/one_third][/container]
效果校验
短代码更新到站点对应位置后,前台刷新页面点击任一横幅,即可在当前标签页正常加载目标商品分类页面,不会再触发新标签页打开的逻辑,原有横幅布局、背景图展示效果完全不受影响。
内容的提问来源于stack exchange,提问作者Williams
相关产品推荐
相关产品推荐

