Global variable to keep term constant throughout theme?
-
I know this sounds convoluted, but I am trying to make a site for 3 dormitories on my campus. The way the information works is that we filtered information for each dorm using taxonomy terms (1 for each school) and adding them to the loops.
Problem is we plan on adding more dorms, and each one has its own set of information that makes it hard to navigate.
I wanted to know if there is a way I can make a front-page form to pick a specific taxonomy term:
school 1, 2, 3
And that variable can be included throughout the theme until someone picks another? So if I pick school 1, every page I go to throughout the site will filter all information and loops with content only with school 1’s taxonomy term.
I was thinking adding a global in functions
function school_global() { global $school; $school = $whatever_term_chosen_from_form }
Then in the loop I could put something like:
$args = array( 'post_type' => 'events', 'school' => $school ); $query = new WP_Query( array( 'post_type' => 'events','taxonomy' => 'school','school' => $school,'posts_per_page' =>'3' ) );
I would also use that variable to retrieve other things that will be named the same, such as link category lists and images.
But my goal is trying to make a form that assigns a global variable that will be embedded into all loops until another variable is assigned. Any ideas?
Solutions like breadcrumbs or multi-site isn’t helpful for many reasons I don’t want to get into, but if anyone can help I appreciate it!
- The topic ‘Global variable to keep term constant throughout theme?’ is closed to new replies.