This topic doesn't apply to the Open Source Online Magazine but it's worth explaining as it's a really useful feature of WordPress theme development.
Say you've been working with the Open Source Online Magazine theme or another one you've developed yourself or downloaded. You decide you want to build a second theme or site with a similar layout and design, or with the content structured in a similar way, but you don't want to start again from scratch.
You could just edit the theme you've already got to create a brand new one. But if your changes aren't huge, it may be better to build a child theme.
A child theme
is a theme which is associated with another theme, called the parent theme. It takes most of its styling and content from the parent theme but has a few things which are different say, for example the archive listings are displayed differently. To do this, you would set up a child theme with its own stylesheet (all child themes need a stylesheet as we'll see shortly), and an archive.php
file. It wouldn't need any other files—not even an index.php
file, as it would take that from the parent theme.
To tell WordPress that a theme is the child of another theme, you have to add some text to the very top of its stylesheet—the style.css
file:
/* Theme Name: My child theme Theme URI: http://example.com/ Description: Child theme for the Open Source Magazine theme Author: Your name here Author URI: http://example.com/about/ Template: opensourcemagazine Version: 1.0 */
Some notes on this text:
Below this commented out code, you add a call to the parent theme's stylesheet:
@import url("../opensourcemagazine /style.css");
After this, you add any styling that's specific to the child theme. You don't need to repeat any styling that's in the parent theme.
When activating your theme in the WordPress theme's admin screen, you simply activate the child theme—WordPress does the rest for you.
Child themes are a great way to build up your own bank of great WordPress themes with less effort than it takes to develop them all from scratch. For more on child themes see http://codex.wordpress.org/Child_Themes.
Q1. What are pretty permalinks?
Q2. Where might you add a widget area to your themes?
sidebar.php
file.footer.php
file.header.php
file.Q3. What steps do you need to take to add a menu to a theme?
functions.php
file, add it to the correct place in the theme (normally in header.php
) and set it up in the Menus admin screen.header.php
file.wp_nav_menu()
code to header.php
then set up the menu using the Menus admin screen.header.php
file.Q4. I'm building a child theme. My parent theme and child theme both have an index.php
and a style.css
file. My parent theme has an archive.php
file and my child theme has a page.php
file. When I visit a category listing on my site, which template file will be used to display it?
index.php
from the parent theme.index.php
from the child theme.archive.php
from the parent theme.page.php
from the child theme.