get_header()
is a WP method. Therefore, to be used, it needs to somehow be within the context of WP. From what I could understand from your question, you created the theme (i.e., index.php
, header.php
, and genre files), but is trying to use the method in a file that is not within the theme. The fatal error is therefore natural.
Wordpress works with a Hierarchy of models, which allows you to create pages of various types in your application following a certain logic. Trying to circumvent such logic (for example, trying to create pages in files outside the CMS structure) is usually not a good idea.
That said, I believe you have two options:
Use WP logic to create pages
There are several tutorials on the internet of how to assemble a theme for WP in the correct way, such as this one. Try creating a template to a page, and within it invoke the method get_header()
(in fact, try to invoke it on your own index.php
, activate your theme on the WP panel, access the site and see what happens). Here you find good instructions on how to do this.
Embed WP functions in your files.
Particularly, I don’t like this solution, although I’ve seen it used extensively around, especially when it comes to integration with legacy applications. But in rare cases (which I don’t believe is yours), it’s the only option. It’s about forcibly including WP methods in files .php
that are outside the logic of the same. For this, it is enough that you make a require
, as follows,
require('/caminho/para/o/arquivo/wp-blog-header.php');
in the external file (which, in your case, I believe is what you are trying to access). This gives the file access to WP methods. You can read about this type of integration here (in English).
As I said, the second solution does not please me, and I believe that, from what I understand of your problem, it is more advantageous to use the WP architecture itself.