Glen Davidson
Glen Davidson

Reputation: 123

get_template_part not working - WordPress

i'm using get_template_part('theme-templates/opt_header1') function in header.php and again using get_template_part('carousal') function in opt_header1.php. however, get_template_part('theme-templates/opt_header1') function in header.php is working fine but i want to use another template part inside the opt_header1.php which is carousal.php but it is not working.

folder structure is like below...

[folder]

     [template-part]

     ... opt_header1.php

     ... carousal.php

     [/template-part]

..header.php

[/folder]

using...

get_template_part('carousal');

please help :)

Upvotes: 3

Views: 3671

Answers (1)

arslan
arslan

Reputation: 408

You need to tell get_template_part() the path of the file to add with reference to the theme's root directory.

So you need to do this:

get_template_part('theme-templates/carousal');

Without telling get_template_part the relative path of the file (carousal.php), the function is looking (and failing) for carousal.php in :

  1. child-theme/carousal.php
  2. parent-theme/carousal.php

Upvotes: 4

Related Questions