繁体   English   中英

根据URL中的锚标记更改PHP简码

[英]Change PHP Shortcode depending on anchor tag in URL

想要根据URL锚显示的内容更改简码。 因此,例如(使用伪代码)

<?php
 if(url="/example-page#anchor1") {
   echo do_shortcode('[example_shortcode_1]')
 }

 if(url="/example-page#anchor2") {
   echo do_shortcode('[example_shortcode_2]')
 }

 if(url="/example-page#anchor3") {
   echo do_shortcode('[example_shortcode_3]')
 }
?>

关于如何执行此操作的任何想法? 做到这一点jQuery的/ JS,如果PHP是不可能的。

如前所述,我可能会解析哈希客户端location.hash ,然后通过jQuery发送值的服务器端,然后运行你的短码和动态填充需要的区域。 如果您要做的事情比这更复杂,那么正如@NappingRabit所说,您可能应该制作多个页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM