Create Named Templates in WordPress

The basic WordPress template files that make up a standard WordPress theme are: index.php, header.php, footer.php, sidebar.php, and style.css. The WordPress theme engine is flexible and gives you several ways of using templates and tags to pull different types of content from your database to display on your website.


After you create a simple theme using the standard templates, there are options available to extend the standard functionality of WordPress so that you have the flexibility to quickly address specific needs for your website.


WordPress recognizes three special areas of a theme: header, footer, and sidebar. The get_header, get_footer, and get_sidebar functions default to loading header.php, footer.php, and sidebar.php, respectively. Each of these functions also supports a name parameter that allows you to load an alternate version of the file. For example, running get_header('main') causes WordPress to load header-main.php.


You may wonder why you’d use the name parameter when you can just create a template file named whatever you like and load it directly. The following are reasons for using the get_header, get_footer, or get_sidebar functions with a name parameter:



  • You use a standard naming convention that users can easily recognize and understand.



  • You can load specialized template files easily and quickly.



  • You offer a fallback that loads the unnamed template file if the named one doesn’t exist. For example, if you use the tag get_header('main'); in your template, but for some reason the header-main.php template file does not exist, WordPress defaults to header.php, which saves the integrity of your website display until you can load the header-main.php file correctly.




In short, use the name parameter feature if you have multiple, specialized Header, Footer, or Sidebar template files.


When you duplicate sections of code in numerous template files, place the code in a separate file and use the get_template_part function to load it where needed.




dummies

Source:http://www.dummies.com/how-to/content/create-named-templates-in-wordpress.html

3 comments:

  1. Thanks for sharing this information
    With more than a decade of experience in working on Cisco Meraki Solutions, we are an established partner that provides sound networking solutions. We help customers migrate their IT infrastructure to the Full Stack of Cisco Meraki Solution with ease. network optimization service in india

    ReplyDelete
  2. How to make money from slot machines - Work Tomake Money
    To make money from slot machines, click titanium mens wedding bands on edc titanium the 'Cashier', or 'Cashier' หาเงินออนไลน์ button. Then click the Cashier and you'll be in titanium ring the slot. You'll notice two or more items babyliss pro titanium straightener

    ReplyDelete