Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.

For the best experience please use the latest Chrome, Safari or Firefox browser.

Use a spacebar or arrow keys to navigate

WDN109 WordPress II

Session 3: Theme Features

Erick Hitter

cdia@ethitter.com

Features?!?!

 

Features?!?!

Two aspects:

Sidebars

 

Sidebars: Tell WP It Exists

Place the following in your theme's functions.php file:

 

function wdn109_register_sidebars() {
	register_sidebar( array(
		'name'          => 'Sidebar',
		'id'            => 'sidebar-1',
		'description'   => 'Appears on posts and pages',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
}
add_action( 'widgets_init', 'wdn109_register_sidebars' );

 

http://codex.wordpress.org/Function_Reference/register_sidebar

Sidebars: Tell WP Where to Show It

Place the following in your theme where the Sidebar should appear:

 

<?php dynamic_sidebar( 'sidebar-1' ); ?>

 

http://codex.wordpress.org/Function_Reference/dynamic_sidebar

Featured Images

 

Featured Images: Adding Support

 

function wdn109_theme_support() {
	add_theme_support( 'post-thumbnails' );
	set_post_thumbnail_size( 400, 300, true );
}
add_action( 'after_setup_theme', 'wdn109_theme_support' );

 

Two elements:

  1. Tell WordPress that the theme supports post thumbnails.
  2. Set dimensions for the default post thumbnail.
    • width
    • height
    • cropping?

 

http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size

Featured Images: Display Images

Place the following in your theme where the image should appear:

 

<?php if ( has_post_thumbnail() )
	the_post_thumbnail(); ?>

 

http://codex.wordpress.org/Function_Reference/has_post_thumbnail

http://codex.wordpress.org/Function_Reference/the_post_thumbnail

Nav Menus

 

Nav Menus: Tell WP

Place the following in your theme's functions.php file:

 

function wdn109_theme_support() {
	register_nav_menu( 'primary', 'Navigation Menu' );
}
add_action( 'after_setup_theme', 'wdn109_theme_support' );

 

http://codex.wordpress.org/Function_Reference/register_nav_menu

Nav Menus: Show the Menu

Place the following in your theme where the menu should appear:

 

<?php wp_nav_menu( array(
	'theme_location' => 'primary',
	'menu_class'     => 'nav-menu'
) ); ?>

 

http://codex.wordpress.org/Function_Reference/wp_nav_menu

Questions?