2
我在header.php中使用get_template_part('theme-templates/opt_header1')函数,并在opt_header1.php中再次使用get_template_part('carousal')函数。然而,header.php中的get_template_part('theme-templates/opt_header1')函数工作正常,但我想使用另一个模板部分opt_header1.php这是carousal.php,但它不工作。get_template_part不工作 - WordPress
文件夹结构是像下面...
[文件夹]
[template-part]
... opt_header1.php
... carousal.php
[/template-part]
..header.php
[/文件夹]
使用...
get_template_part('carousal');
ple ase帮助:)
感谢您的快速回复。但让我告诉你,我想在** opt_header1.php中使用** carousal **这两个文件都在它们的根上。 我仍然需要添加“主题模板/”? –
是的,你:) 请注意主题的根是主题文件夹。 '主题模板'是一个子文件夹。 get_template_part函数需要被告知要从主题的根视角相应添加的文件 - 无论您在子文件夹内部有多深。 –
谢谢,它工作:) –