Quick Theme / Function question
-
I am trying to create a global variable that can be access throughout the entire theme, ie the header, footer and sidebar, single and page .php files.
I have added the code block below to my function.php file
function determine_thing($post){ global $post; global $thingType; $thingType = ""; $id = $post->ID; $thingType = get_post_meta($id,'thingtype',true); $category = get_the_category($id); switch ($category[0]->slug) { case "thing": $thingType = "a"; break; case "thing2": $thingType = "b"; break; default: $thingType = "c"; break; } return $thingType; } add_action('the_thing', 'determine_thing');
I believe the registration of this function was successful but i am at a loss of how to call it? I have tried the code block below and its not working. Also will this actually achieve what i want?
global $post; $thingType = do_action('the_thing', $post);
thanks in advance
Ilan
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Quick Theme / Function question’ is closed to new replies.