2

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.

brasofilo
  • 25,496
  • 15
  • 91
  • 179
Akin A
  • 33
  • 1
  • 1
  • 5
  • 1
    Have you already seen https://codex.wordpress.org/Function_Reference/get_header? – user3783243 Jul 29 '18 at 21:24
  • Before loading `index.php`, Wordpress loads `functions.php` (of the current theme). So, the logical and the includes are in `functions.php`. Some informations here : https://wordpress.stackexchange.com/questions/71406/is-there-a-flowchart-for-wordpress-loading-sequence – Vincent Decaux Jul 29 '18 at 21:25
  • @VincentDecaux YES! I'm really a stupid I was knowing the functions are including. Thank u Vincent. – Akin A Jul 29 '18 at 21:30
  • Also a useful trick can be `grep`ing your code base. `grep -E 'function\s+get_header\(\)' --include="*.php" -r .` from the root of your code base should bring but scripts that define that function. – user3783243 Jul 29 '18 at 21:31

1 Answers1

5

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;
?>