I'm trying to load a template in print_table()
function. If I uncomment the include_once code above, it will work. Why? the get_template function
does exactly the same. As it is now it says $people is undefined.
function get_template( $template_name ) {
include_once __DIR__ . DIRECTORY_SEPARATOR . $template_name;
}
function print_table( $people ) {
// include_once __DIR__ . DIRECTORY_SEPARATOR . 'html/table.php';
get_template( 'html/table.php' );
}
in html/table.php
<table>
<tr>
<th>Name</th>
<th>Author</th>
<th>Date</th>
</tr>
<?php dd($people); ?>
</table>