开发者

wordpress - how to get php variable in page from sidebar

开发者 https://www.devze.com 2022-12-19 04:19 出处:网络
I wrote my own custom page template for my Wordpress page, now I want to change sidebar.php to insert a sm开发者_开发知识库all menu whenever that page template is loaded.

I wrote my own custom page template for my Wordpress page, now I want to change sidebar.php to insert a sm开发者_开发知识库all menu whenever that page template is loaded.

// sidebar.php
if ( isset($event_name) ) {
  // do something
}

But apparently sidebar.php doesn't recognize variable $event_name.

How do I come about solving this?


While I'm not familiar with the way WordPress implements templates, have you tried declaring the variable global in the sidebar page?


See: Function Reference/is page template « WordPress Codex to be able to detect page template in use.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号