Page Nav




Classic Header


Top Ad

Breaking News:


Themes & Templates ; For Wordpress

Themes & Templates ; For Wordpress Template files  WordPress themes are made from template files. These are PHP files tha...

Themes & Templates ; For Wordpress

Image result for wordpress themes

Template files 
WordPress themes are made from template files. These are PHP files that contain a mix of HTML, Template Tags, and PHP code.

When you are building your theme, you'll use template files to affect the layout and style of various parts of your website. for instance , you'd use the header.php template to make a header, or the comments.php template to incorporate comments.

When someone visits a page on your website, WordPress loads a template supported the request. the sort of content that's displayed in by the template file is decided by the Post Type related to the template file. The Template Hierarchy describes which template file WordPress will load supported the sort of request and whether the template exists within the theme. The server then parses the PHP within the template and returns HTML to the visitor.

The most critical template file is index.php, which is that the catch-all template if a more-specific template can't be found within the template hierarchy. Although a topic only needs a index.php template, typically themes include numerous templates to display different content types and contexts.

Top ↑

Template partials #Template partials
A template partial may be a piece of a template that's included as a neighborhood of another template, like a site header. Template partials are often embedded in multiple templates, simplifying theme creation. Common template partials include:

header.php for generating the site’s header
footer.php for generating the footer
sidebar.php for generating the sidebar
While the above template files are special-case in WordPress and apply to only one portion of a page, you'll create any number of template partials and include them in other template files.

Top ↑

Common WordPress template files #Common WordPress template files
Below may be a list of some basic theme templates and files recognized by WordPress.

The main template file. it's required altogether themes.
The main stylesheet. it's required altogether themes and contains the knowledge header for your theme.
The right-to-left stylesheet is included automatically if the web site language’s text direction is right-to-left.
The comments template.
The front page template is usually used because the site front page if it exists, no matter what settings on Admin > Settings > Reading.
The home page template is that the front page by default. If you are doing not set WordPress to use a static front page, this template is employed to point out latest posts.
The header template file usually contains your site’s document type, meta information, links to stylesheets and scripts, and other data.
The singular template is employed for posts when single.php isn't found, or for pages when page.php aren't found. If singular.php isn't found, index.php is employed .
The single post template is employed when a visitor requests one post.
The single post template used when a visitor requests one post from a custom post type. for instance , single-book.php would be used for displaying single posts from a custom post type named book. The index.php is employed if a selected query template for the custom post type isn't present.
The archive post type template is employed when visitors request a custom post type archive. for instance , archive-books.php would be used for displaying an archive of posts from the custom post type named books. The archive.php template file is employed if the archive-{post-type}.php isn't present.
The page template is employed when visitors request individual pages, which are a built-in template.
The page slug template is employed when visitors request a selected page, for instance one with the “about” slug (page-about.php).
The category template is employed when visitors request posts by category.
The tag template is employed when visitors request posts by tag.
The taxonomy term template is employed when a visitor requests a term during a custom taxonomy.
The author page template is employed whenever a visitor loads an author page.
The date/time template is employed when posts are requested by date or time. for instance , the pages generated with these slugs:
The archive template is employed when visitors request posts by category, author, or date. Note: this template are going to be overridden if more specific templates are present like category.php, author.php, and date.php.
The search results template is employed to display a visitor’s search results.
The attachment template is employed when viewing one attachment like a picture , pdf, or other media file.
The image attachment template may be a more specific version of attachment.php and is employed when viewing one image attachment. If not present, WordPress will use attachment.php instead.
The 404 template is employed when WordPress cannot find a post, page, or other content that matches the visitor’s request.
Top ↑

Using template files #Using template files
Within WordPress templates, you'll use Template Tags to display information dynamically, include other template files, or otherwise customize your site.

For example, in your index.php you'll include other files in your final generated page:

To include the header, use get_header()
To include the sidebar, use get_sidebar()
To include the footer, use get_footer()
To include the search form, use get_search_form()
To include custom theme files, use get_template_part()
Here is an example of WordPress template tags to incorporate specific templates into your page:

<?php get_sidebar(); ?>
<?php get_template_part( 'featured-content' ); ?>
<?php get_footer(); ?>


No comments