WordPress Theme Authoring in template and bottom template, wordpress head _php Tutorial

Source: Internet
Author: User

WordPress Theme Authoring in template and bottom template, WordPress head


Get_header () (Get head)
Introduce the theme of the header template, the default will be introduced in the current theme directory of the header.php file. If a name is specified, the header-{name}.php file of the current theme directory is introduced and the wp-includes/theme-compat/header.php file is introduced if the file that needs to be introduced does not exist.

Usage

Get_header ($name);

Parameters

$name

(string) (optional) The name of the file to be introduced, or, if specified, the header-{$name}.php file.

Example

<?php Get_header ();?>

The above code will introduce the header.php file to the root of the current theme.

<?php get_header (' main ');?>

The above code will introduce the header-main.php file to the root of the current theme.

if (Is_home ()) Get_header (' home '), ElseIf (is_404 ()) get_header (' 404 '); else Get_header ();

The above code will introduce the header-home.php file at the root of the current theme on the homepage, 404 pages into the header-404.php file of the current theme root directory, and the other pages will introduce the header.php file of the current theme root directory.

Other

This function is located at: wp-includes/general-template.php


Get_footer () (Get bottom)
Get_footer () is used to introduce the bottom template file. If the specified name is introduced into the footer-{name}.php file of the root of the current theme, if you do not specify the footer.php file that introduces the root of the current theme, introduce wp-includes/theme-compat/if the file does not exist footer.php file.

Usage

Get_footer ($name);

Parameters

$name

(string) (optional) introduces the name of the template and, if specified, introduces the footer-{$name}.php file.

return value

There is no return value for this function.

Example

footer.php file that introduces the root directory of the current theme:

<?php Get_footer ();?>

footer-new.php file that introduces the root directory of the current theme:

<?php get_footer (' new ');?>

Introduce different bottom template files according to different pages:

if (is_404 ()) get_footer (' 404 '),//If 404 pages are introduced to the current topic root directory footer-404.php file ElseIf (Is_home ()) get_footer (' home ');//If it is the first Page introduces the current theme root directory of the footer-home.php file else Get_footer ();//If it is not the first page or 404 pages introduce the current theme root directory of the footer.php file

Other

This function is located at: wp-includes/general-template.php

Articles you may be interested in:

    • Explain the PHP functions used to get Comment templates and search forms in WordPress
    • Introduction of template file for WordPress theme making

http://www.bkjia.com/PHPjc/1085876.html www.bkjia.com true http://www.bkjia.com/PHPjc/1085876.html techarticle WordPress Theme to get the header template and the bottom template, WordPress head get_header () (Get the head) into the theme of the header template, the default will be introduced in the current theme directory ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.