Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 600 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make get_header() call a custom header file located in a sub-folder of the theme?

#1
From a PHP template file located in a sub-folder of my WP theme folder (`my_theme/subfolder/my_file.php`) I want to use `get_header()` and call a custom `header-new.php` located in the same sub-folder.

Instead, `get_header(header-new)` loads `header.php` located in my theme root folder. How to fix that problem?
Reply

#2
you can use :

get_template_part('header-new.php');

>reference here: >https://developer.wordpress.org/reference/functions/get_template_part/
Reply

#3
You are correct to use get_header() function. However, as per [documentation][1] you should pass the name of the custom header in the specific format - only the part that comes between 'header-' and '.php'. E.g. for the custom header in the file:

header-custom.php

you should use:

get_header('custom');

But that's not all. It is important to remember that the custom header file should be placed in 1 or 2 specific directories, depending on whether you're working on parent or child theme:

1. Parent theme: you should place it either in the same directory as the page template or the 'root' theme directory (specifically the same directory where your style.css is)
2. Child theme: you have to place it in the 'root' child theme directory

get_header() function calls [locate_template() function][2], which searches for the custom header file in those 2 directories. If it doesn't find the file, it defaults to 'header.php'.


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through