wordpress - how to get php variable in page from sidebar
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.
精彩评论