
Using Action Hooks in WordPress Child Themes In this post we’ll review how to write a PHP function and go over the basic idea of how you can use Action Hooks in your WordPress Theme. We’ll take a look at a practical example of injecting a Welcome Blurb into your Theme without touching the existing code and we’ll also look at how to remove existing content being injected into Theme Hooks. Packing Up A Function Action hooks are in a lot of WordPress Themes nowadays. There’s a good reason for that but you’re probably wondering what the big deal is right? If you want to get started with them we’re going to have to take a look at how to write a PHP function again. So that’s how you write a PHP function. You’ve seen the same thing before with WordPress functions like wp_list_pages() or the_content(). The Basic Idea Behind Action Hooks A lot of really smart theme developers have started adding what are essentially empty functions to their themes ready to be filled up with stuff. Adding Content To An Action Hook Like this: Like Loading...
Child Themes Languages: বাংলা • English • Italiano • 日本語 • 한국어 • Español • Nederlands • Français • Português do Brasil • Русский • Slovenčina • ไทย • 中文(简体) • 中文(繁體) • Македонски • (Add your language) A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes are the recommended way of modifying an existing theme. Why use a Child Theme? There are a few reasons why you would want to use a child theme: If you modify a theme directly and it is updated, then your modifications may be lost. How to Create a Child Theme Creating a Child Theme from an Unmodified Parent Theme A child theme consists of at least one directory (the child theme directory) and two files (style.css and functions.php), which you will need to create: The child theme directory style.css functions.php The first step in creating a child theme is to create the child theme directory, which will be placed in wp-content/themes. A couple things to note: <? Template Files <? if ( !
Page Templates Page Templates Pages are one of WordPress's built-in Post Types. You'll probably want most of your website Pages to look about the same. Selecting a Page Template Your Theme files should include a default page template (named: page.php). Edit Page Screen: You can assign a custom template for any individual Page by using the Template dropdown in the Edit Page screen (part of the Page Attributes module): Select a Template from the list (e.g., My Custom Page). All Pages Screen: The Quick-Edit and Bulk Edit options on the All Pages screen also have Template dropdowns. Template List Will Show Only If: There is at least one custom page template file in your active Theme's folder. Creating a Page Template WordPress offers several ways to display Pages. Conditional Tags Edit your default template: You can often make smaller Page-specific changes with Conditional Tags in your Theme's page.php file. Specialized Page Template page-{slug}.phppage-{ID}.php /wp-content/themes/my-theme/ Custom Page Template <?
Thirty Ten | Just another Twenty Ten Child Theme Introducing Thirty Ten WordPress 3.0 is introducing a new theme that is light years ahead of Kubrick (also known as default in the backend), that looks so good you won’t even mind running it on a live site. In addition to being a beautiful theme in it’s own right, it’s also easy to build upon and create your own child themes for. I’m not allowed to override any of the template files with my own version. Version 1.1.4 I fixed a couple of bugs and have released a new version. Version 1.1.3 I just uploaded a small update to fix a bug with adding additional themes. Version 1.1.2 I’ve just uploaded version 1.1.2 which makes use of the new edit_theme_options capability introduced in 14111. Three Columns, Three Ways I was looking at a friend’s site that is running Thirty Ten and it got me thinking. And then I thought, why not just give the user the option. On the right: Or the default center: This option can be managed from the Thirty Ten settings page. And turn it into this:
The Best Wordpress Plugins Advertisement WordPress is the most widely used and adaptable content management system out there, but you’re probably going to want some plugins to make it just right for your needs. Here, I’ve collated what I think are the best plugins – both from experience, and community recommendations. Remember though, the more plugins you install, the slower your site will be, so there’s a delicate balancing act between features and performance. Performance and Backup WordPress is great – but can be quite slow when faced with lots of traffic. Note: Many of these plugins should only be configured by advanced users – they could potentially break your site, so take care. W3 Total Cache The Swiss Army knife of caching and performance plugins, W3 handles everything from page caching to Content Delivery Networks and file minification. Better WordPress Minify Make no mistake, W3 Total Cache is a behemoth that can seem like it needs an engineering degree to set up correctly. WP SuperCache CloudFlare Duplicator
Category Templates Category Templates When a viewer clicks on a link to one of the Categories on your site, he or she is taken to a page listing the Posts in that particular Category in chronological order, from newest Posts at the top to oldest at the bottom. There are many display choices, including whether to display the complete post or post excerpts, and what additional information to display (title, author, publish date, last modified time, etc.). Each theme makes different choices, and you might want to change them. This article explains how to change what happens when the blog viewer is visiting one of your site's Category pages. Permalinks to category archives are controlled Using Permalinks settings. What Template File is Used? The first step in modifying what happens when someone visits a Category page is to figure out which of your theme's files is going to be used to display the posts. In the case of categories, the hierarchy is fairly simple. Adding Text to Category Pages Static Text Above Posts
Widgetizing Themes Languages: English • Français • 日本語 • Português do Brasil • 中文(简体) • Македонски • (Add your language) What is Widgetizing? Widgetizing is a pseudo word that describes the process of implementing Widgets and Widget Areas into your Theme. How to Register a Widget Area The following should be added to your Theme's functions.php file: <? How to display new Widget Areas You can display your new widget area by: Adding the code directly to a theme file like the sidebar.php file; or Using a custom function with hook in your functions.php file. Here's some example code that is a common way to add your new widget area to a parent or child theme: The above code can be added to your sidebar.php file. This is the function which outputs the widget: The code above will display the widget registered with an ID value of 'home_right_1'. For more information, please refer to the Widgets API to learn how to, programmatically, display Widgets and Widget Areas. Create New Widget Area Using Custom Function Resources
Designing for WordPress: Complete Series & Downloads Over the last few weeks, I have been been doing a video screencast series on Designing for WordPress. It is a three-part series which covers downloading and installing WordPress on a server all the way to a completed theme. Part One: Download, Install, "Reset" Theme Video PageDirect Video Download (.mov) Part Two: Structure Video PageDirect Video Download (.mov) Part 3: Finishing Touches, Extra Stuff Video PageDirect Video Download (.mov) Download - "Personal Homepage Theme" I figured I might as well call it what it is! I literally designed this for use on my personal site, so you can see it live on chriscoyier.net. Download Theme Note: The orginal Photoshop file is included in the download in a folder called "orig" in the theme folder. In case you don't already know. Share On
Stepping Into Templates Stepping into Templates Languages: English • 日本語 • 中文(简体) • (Add your language) Template files are the building blocks of your WordPress site. They fit together like the pieces of a puzzle to generate the web pages on your site. Some templates (the header and footer template files for example) are used on all the web pages, while others are used only under specific conditions. A traditional web page consists of two files: The XHTML page to hold the structure and content of the page and the CSS Style Sheet which holds the presentation styles of the page. In WordPress, the (X)HTML structure and the CSS style sheet are present but the content is generated "behind the scenes" by various template files. The WordPress Page Structure A simple WordPress web page structure is made up of three basic building "blocks": a header, the content, and a footer. Basic Template Files To generate such a structure within a WordPress Theme, start with an index.php template file in your Theme's directory.