I am creating a custom WordPress theme and what I want is to define a global variable in theme file and call that variable in plugin files. I searched on google and many StackOverflow posts about this topic for instance :
creating function in the theme file
<?php
function ww_new(){
global $ww_new;
$ww_new = $post_slug;
}
add_action('wp_roles_init', 'ww_new');
?>
and call it in the plugin file
global $ww_new;
echo $ww_new;
but this approach doesn't work for me. Any clue regarding this?