0

我正在使用 get_template_part 从其他文件调用另一个代码。当我使用这样的代码时它工作正常: include get_template_part('category1', 'page');

我想使用另一个代码,从我的选项面板调用,然后我将代码更改为:

 <?php
 $post = $wp_query->post;
 if (in_category($up_options->cat1)) {
 include get_template_part($up_options->category1, 'page');
 } elseif (in_category($up_options->cat2)) {
 include get_template_part($up_options->category2, 'page');
 } else {
 include get_template_part('category1', 'page');
 } 
 ?> 

然后我得到一个错误:

 Warning: include() [function.include]: Filename cannot be empty in D:\0-SERVER\iwpserver\htdocs\wordpress\wp-content\themes\Blogbold\category.php on line 40

 Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.;D:\0-SERVER\iwpserver\server\php\PEAR') in D:\0-SERVER\iwpserver\htdocs\wordpress\wp-content\themes\Blogbold\category.php on line 40

第 36 和 40 行包含以下代码:

 Line 36 = include get_template_part($up_options->category1, 'page');
 Line 40 = include get_template_part('category1', 'page');

非常感谢您的帮助。谢谢。

4

0 回答 0