Akin A
Akin A

Reputation: 43

How is get_header() calling a specific PHP file?

I'm trying to learn Wordpress Structure with investigating some free plugins/themes.

I'm working on "Renger Blog Theme" right now, but I couldn't understand something. I've checked get_header() page in the WP manual but it still looks like a magic :)

This theme has custom function codes in

wordpress\wp-content\themes\renderblog\inc\renderoption.php 

and this theme calling this file with just

get_header();

in index.php

There is no include code in header.php or wherever else.

How it's calling this specific PHP file with get_header()? Is it like a way to include automatically all files in the inc folder?

When I just delete get_header() from the index.php, the functions are not working.

Upvotes: 3

Views: 19164

Answers (1)

Infoconic Technologies
Infoconic Technologies

Reputation: 414

WordPress get_header() is the function predefined by WordPress inbuilt structure. This function Includes the header template for a theme or if a name is specified then a specialized header will be included.

if the file is called "header-new.php" then specify "new".

For example <?php get_header('new'); ?>

Another example for Different headers for different pages.

<?php
// if detect home page of wordpress
if ( is_home() ) :
    get_header( 'home' );
// if detect Not found page 404 of wordpress
elseif ( is_404() ) :
    get_header( '404' );
// default header if nothing specific is detected
else :
    get_header();
endif;
?>

Upvotes: 6

Related Questions