Pass a PHP variable to another file
The WordPress template functions don’t support passing variables (to my knowledge) by default, so you need to write your own function. For example like this, // functions.php function my_template_include_with_variables( string $path=””, $data = null ) { $file = get_template_directory() . “https://wordpress.stackexchange.com/” . $path . ‘.php’; if ( $path && file_exists( $file ) ) { // … Read more