Hướng dẫn tạo themes cho wordpress part 3 - Pdf 16

Chapter 1
25
After you've chosen a theme framework, it is time to create a theme based on that framework.
To do so, you'll use the technique described in Creating a child theme. After you've created the
base child theme, you can start to customize it.
In most cases, you override the markup of a parent theme by supplying template les directly
in your child theme. With a theme framework, things generally work a little differently. You
supply your custom markup by attaching callbacks to custom action and lter hooks, as
dened by the theme framework. To nd out what the custom hooks are, you need to
read the theme framework's documentation.
To add appropriate functionality via the custom hooks, you create a
functions.php le
inside your child theme, and use the Plugin API to add callbacks to the theme framework's
custom hooks.
How it works
A theme framework is a theme created for the sole purpose of being extended by child
themes. They are built to be modied by users for use on their own websites. Although most
theme frameworks can be used out of the box, it is the personalization and customization
that end users and developers perform that really allow their particular use of the framework
to shine.
There's more
There are several quality theme frameworks in existence at the time of writing this book. The
best are as follows:
Thematic—
/>Hybrid— />theme-framework
Carrington— />Vanilla— />Whiteboard— />wordpress-theme-framework/
WPFramework— />See also
Installing and activating a theme
Creating a child theme



How it works
Plugins use these hooks to add to or modify the rendered output of a theme's template les.
Often the modication includes linking to or outputting JavaScript, CSS, or HTML code. Many
popular plugins use the above hooks, and making sure that they are present is essential to
the plugin's proper operation.



Chapter 1
27
There's more
Although wp_head, wp_footer, and comment_form are the only hooks necessary for a
complete theme, it is possible to add many more custom hooks that allow individuals to
customize a theme after it has been fully developed by its author.
Including PHP les from your theme
For organizational or reuse purposes, you will often separate components of your theme into
separate les to be used in several different places.
Getting ready
Before getting started, you need to identify the pieces of output that will be reused throughout
your theme, and separate them into different PHP les. You may wish to separate common
post listing structures or advertisement blocks.
How to do it
First, you should identify the piece of output that you wish to reuse and separate it into a new
le. For this recipe, we'll say that you have a notice snippet that you may wish to include in
several places. Place the following code in a new le called notice-snippet.php:
<div class="notice-snippet">
Thanks for visiting my site!
</div>
After you've separated it, you need to decide where you want to display the snippet. Wherever
you want to display the snippet, insert the following:

Introduction
One of the most important aspects of any website is navigation. Making sure that a visitor can
get around is paramount to increasing trafc, user engagement, and visit length. By offering a
variety of navigation methods, you give the user multiple ways to nd the content that interests
them. There are several techniques built into WordPress that you can use to build the navigation
that lets your users nd what they need on your site.
When thinking about the topic of navigation in the context of this chapter, it is important to
also consider the subject as a whole. Don't limit yourself to the concept of a top or side main
navigation item. Those types of navigation are very important, but for the purposes of this
chapter, you'll consider navigation as a whole—meaning any way that helps the user to get
around your site.









Creating Navigation
30
Listing all of the pages that exist on a blog
WordPress pages often contain static content that should be reachable at any time. Common
uses for WordPress pages are website and author descriptions, contact forms, afliate
information, and more. Making sure that these pages can be found and navigated to
quickly is paramount.
How to do it
First, decide where you want to generate a linked list of all your pages. If you're comfortable
using pages for navigation, then you probably want to put the pages listing directly below your

<li class="page_item page-item-273">
<a title="Terms &amp; Conditions"
href="al/terms-conditions/">Terms &amp;
Conditions</a>
</li>
<li class="page_item page-item-256 current_page_item">
<a title="WP List Pages"
href="al/list-pages/">WP List Pages</a>
</li>
</ul>
</li>
There's more
The default output for wp_list_pages might not t your specic use cases. Luckily,
modifying the output from wp_list_pages is easy.
Passing parameters
The wp_list_pages output can be changed by passing different values for a wide array of
parameters, as follows:
<?php
wp_list_pages(array('parameter_name' => 'parameter_value'));
?>
Creating Navigation
32
Some of the more important parameters are as follows:
Parameter Name Effect
echo
Set to false to cause wp_list_pages to return a string containing
HTML markup instead of printing the markup
child_of
Pass a numeric ID to only retrieve child pages of the page with that ID
exclude

How it works
When you call wp_list_categories, WordPress performs a database query, fetching all
of the categories that match the parameters that you pass to the function. After fetching the
categories, WordPress builds the markup for the list. The markup consists of an <li> tag
containing a link to the categories archive page for each category that was fetched. If the
title_li parameter is not empty, then the entire list is wrapped in a containing <li>. By
default, the previous code will produce markup that is similar to the following:
<li class="categories">Categories<ul>
<li class="cat-item cat-item-3">
<a title="View all posts filed under aciform"
href="al/category/aciform/">aciform</a>
<ul class="children">
<li class="cat-item cat-item-41">
<a title="View all posts filed under sub"
href="al/category/aciform/sub/">sub</a>
<ul class="children">
<li class="cat-item cat-item-102">
Creating Navigation
34
<a title="View all posts filed under sub sub"
href="al/category/aciform/sub/sub-sub/"
>sub sub</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="cat-item cat-item-4">
<a title="View all posts filed under antiquarianism"
href="al/category/antiquarianism/"


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status