I have since tried a blank and new php file and accessing it the same way - that worked. So I am now unclear why the existing file does not load at all. There are no errors. Here is the code start of the template part I am getting:
<?php
require_once WP_PLUGIN_DIR.'/themename/includes/file1.php';
require_once WP_PLUGIN_DIR.'/themename/includes/file2.php';
require_once WP_PLUGIN_DIR.'/themename/includes/file3.php';
if(isset($_GET["ict"])){
$id_category[] = "'{$_GET["ict"]}'";
$variable1= new file3();
I am trying to include a partial template and have read up on how to do so.
<div class="row">
<div class="col-md-12">
<?php get_template_part('/partials/category.php');
?>
</div>
</div>
The file I have included the above code in is in the theme main. The partial is in a folder in the theme main called partials. When I use /partials/category.php
I get a blank with no PHP error in the area of the page where the information should be.
If I dont use the /
on front of partials I get an error.
I have also tried removing the /
on the front and at the same time removing the .php
at the end. Same result where there is no error and no output
What am I missing about getting the template part to display>?
Here is the blank space where this should display
I have since tried a blank and new php file and accessing it the same way - that worked. So I am now unclear why the existing file does not load at all. There are no errors. Here is the code start of the template part I am getting:
<?php
require_once WP_PLUGIN_DIR.'/themename/includes/file1.php';
require_once WP_PLUGIN_DIR.'/themename/includes/file2.php';
require_once WP_PLUGIN_DIR.'/themename/includes/file3.php';
if(isset($_GET["ict"])){
$id_category[] = "'{$_GET["ict"]}'";
$variable1= new file3();
I am trying to include a partial template and have read up on how to do so.
<div class="row">
<div class="col-md-12">
<?php get_template_part('/partials/category.php');
?>
</div>
</div>
The file I have included the above code in is in the theme main. The partial is in a folder in the theme main called partials. When I use /partials/category.php
I get a blank with no PHP error in the area of the page where the information should be.
If I dont use the /
on front of partials I get an error.
I have also tried removing the /
on the front and at the same time removing the .php
at the end. Same result where there is no error and no output
What am I missing about getting the template part to display>?
Here is the blank space where this should display
Share Improve this question edited Mar 3, 2021 at 1:13 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Mar 2, 2021 at 23:35 user15081222user15081222 1033 bronze badges 18 | Show 13 more comments1 Answer
Reset to default 0Your get_template_part
call is successful, it's the file it loads that is broken
<?php get_template_part( 'partials/category' ); ?>
If you swap the contents of that file for this:
<p>Hello World</p>
Then it will work as expected.
The cause of your problem is this:
require_once WP_PLUGIN_DIR.'/themename/includes/file1.php';
- you should not be including files from other themes directly
- themes don't go in the plugins/
WP_PLUGIN_DIR
folder - PHP can't find the file so it exits with a fatal error
You should see confirmation of this in your PHP error log
.php
extension? – Tom J Nowell ♦ Commented Mar 2, 2021 at 23:43partials/category.php
actually has output? – Tom J Nowell ♦ Commented Mar 2, 2021 at 23:56