SlideShare a Scribd company logo
Building a WordPress Theme
Not too difficult
A little harder
#*&%@#!
why build a theme?
• better understanding of how WordPress works
• self-sufficiency to fix or change theme aspects
• empowerment ( yourself, a career )
• move beyond the WordPress dashboard
• world domination…results may vary
World 1-1
Templates
template terminology
• template files - files that control how your site content is
displayed
• template tags - WordPress functions that grab content from
the database (get_header, get_sidebar(‘someparameter’))
• page templates - type of template that is only applied to
pages in your theme
• files to display your data - WordPress template files (php)
• files for theme information and styles - style.css
• files to add/remove functionality (functions.php)
• other files used can include javascript, images, svg, sass/less
and more!
theme files
index.phpstyle.css
Required Theme Files
create a folder, place these two files and you’ll soon have your theme
style.css
• file header - provides details about theme in the form of
comments
• can house css styles for your site
style.css
/*
Theme Name: Twenty Fifteen
Theme URI: https://wordpress.org/themes/twentyfifteen/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Our 2015 default theme is clean, blog-focused, and designed for clarity. Twenty Fifteen's simple,
straightforward typography is readable on a wide variety of screen sizes, and suitable for multiple languages.
Version: 1.1
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, blue, gray, pink, purple, white, yellow, dark, light, two-columns, left-sidebar,featured-images,
microformats, post-formats
Text Domain: twentyfifteen`
*/
Dashboard - Theme Details
style.css
/*
Theme Name: Twenty Fifteen
*/
// begin theme styles
index.php
https://gist.github.com/philiparthurmoore/b1f47c15d3eb2c573924
<!DOCTYPE html>
<html>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="stylesheet" href="<?php echo esc_url( get_stylesheet_uri() ); ?>" type="text/css" />
<?php wp_head(); ?>
</head>
<body>
<h1><?php bloginfo( 'name' ); ?></h1>
<h2><?php bloginfo( 'description' ); ?></h2>
index.php
https://gist.github.com/philiparthurmoore/b1f47c15d3eb2c573924
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<?php endwhile; ?>
<?php if ( get_next_posts_link() ) { next_posts_link(); } ?>
<?php if ( get_previous_posts_link() ) { previous_posts_link(); } ?>
<?php else: ?>
<p>No posts found. :(</p>
<?php endif; ?>
index.php
https://gist.github.com/philiparthurmoore/b1f47c15d3eb2c573924
<?php wp_footer(); ?>
</body>
</html>
most themes include these files
header.php index.php sidebar.php footer.php
header.php
<!DOCTYPE html>
<html>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="stylesheet" href="<?php echo esc_url( get_stylesheet_uri() ); ?>" type="text/css" />
<?php wp_head(); ?>
</head>
<body>
<h1><?php bloginfo( 'name' ); ?></h1>
<h2><?php bloginfo( 'description' ); ?></h2>
footer.php
<?php wp_footer(); ?>
</body>
</html>
sidebar.php
<?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
<div id="primary-sidebar" class="primary-sidebar widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div><!-- #primary-sidebar -->
<?php endif; ?>
working index.php
<?php get_header() ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<?php endwhile; ?>
<?php if ( get_next_posts_link() ) { next_posts_link(); } ?>
<?php if ( get_previous_posts_link() ) { previous_posts_link(); } ?>
<?php else: ?>
<p>No posts found. :(</p>
<?php endif; ?>
<?php get_sidebar() ?>
<?php get_footer() ?>
page reference
content
header.php
sidebar.php
footer.php
the loop
• used to display posts, page content, comments, custom post
types, custom fields
• when you read about certain functions that list only working
in the loop, this is where it goes
• https://codex.wordpress.org/The_Loop
Blog Archive
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
<?php endwhile; else: ?>
<?php _e('Sorry, no posts matched your criteria.'); ?>
<?php endif; ?>
Individual Post
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; else: ?>
<?php _e('Sorry, no pages matched your criteria.'); ?>
<?php endif; ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; else: ?>
<?php _e('Sorry, no pages matched your criteria.'); ?>
<?php endif; ?>
Template Tags
World 2-1
template tags
• a piece of php code that tells WordPress “do” or “get” something
• they separate the theme into smaller, more understandable,
sections.
• some tags can only be used in specific areas
• values can be passed through tags to display specific content
working index.php
<?php get_header() ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_title(‘<h3>’, ‘</h3>’); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php if ( get_next_posts_link() ) { next_posts_link(); } ?>
<?php if ( get_previous_posts_link() ) { previous_posts_link(); } ?>
<?php else: ?>
<p>No posts found. :(</p>
<?php endif; ?>
<?php get_sidebar() ?>
<?php get_footer() ?>
General
collect them all: https://codex.wordpress.org/Template_Tags
get_header()
get_footer()
get_sidebar()
Author
wp_list_authors()
the_author()
the_author_link()
Bookmark
wp_list_bookmarks()
get_bookmark()
Category Comment
Link
the_permalink()
home_url()
site_url()
Post
the_content()
the_excerpt()
the_title()
Post Thumbnail
the_post_thumbnail()
has_post_thumbnail()
Navigation
wp_nav_menu()
template tag categories
comment_author()
comment_date()
get_avatar()
the_category()
the_tags()
the_terms()
Conditionals
conditionals
if ( is_user_logged_in() ) {
echo 'Welcome, registered user!';
} else {
echo 'Welcome, visitor!';
}
https://developer.wordpress.org/themes/basics/conditional-tags/
if ( is_front_page() ) {
// do something
}
Template Hierarchy
World 3-1
• Query strings (data from page links) determine which
template or set of templates to display page content
• Templates are selected in the order determined by the
template hierarchy
• If a template file cannot be matched, index.php will be used
query string - http://example.com/
template flow
front-page.php home.php page.php index.php
query string - http://example.com/blog/category/luigi/
template flow
category-luigi.php category-6.php category.php
archive.php index.php
template hierarchy
http://wphierarchy.com/ - Rami Abraham, Michelle Schulp
expanded theme
header.php index.php sidebar.php footer.php
404.php single.php page.php
page templates
• only apply to pages
• used to change the look and feel of a page
• can be applied to a single page, page section or class of
pages
• custom pages with template names give users control by
enabling template switching
page template flow
$custom.php
page-$slug.php page-id.php page.php
page query
Custom Page Template
/**
* Template Name: Two Columns Template
*
* Description: A page template that provides a key component of WordPress as
* a CMS by meeting the need for a carefully crafted introductory page.
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
Theme Folder Structure
World 4-1
folder setup
• main theme template files are in the root directory
• no required folders in themes at this time
• page-templates folder, languages folder are auto
recognized
archive.php
comments.php
image.php
content.php
index.php page.php
header.php
sidebar.php
screenshot.png search.php
single.php style.css
footer.php
css inc images languages
page-
templates
Twenty Fifteen Theme Structure
404.php author-bio.php
content-*.php
functions.php
rtl.css
Functions and Hooks
World 5-1
functions file
• adds/removes features and functionality to your theme
• acts like a plugin
• automatically loaded for both admin and external pages
• “put it in your functions file” location
• enqueuing stylesheets and scripts
• enable theme features, including: sidebars, post formats,
custom headers/backgrounds
• enable options for the theme customizer
• define functions for your theme to use
• and more
functions.php
if ( ! function_exists( 'themename_setup' ) ) :
function themename_setup() {
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'theme_name' ),
'secondary' => __( 'Secondary Menu', 'theme_name' )
) );
add_theme_support( 'post-thumbnails' );
}

endif;
add_action( 'after_setup_theme', 'themename_setup' );
header.php
<!DOCTYPE html>
<html>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="stylesheet" href="<?php echo esc_url( get_stylesheet_uri() ); ?>" type="text/css" />
<?php wp_head(); ?>
</head>
<body>
<h1><?php bloginfo( 'name' ); ?></h1>
<h2><?php bloginfo( 'description' ); ?></h2>
functions.php
function twentyfifteen_scripts() {
// Load our main stylesheet.
// hooks into wp_head();
wp_enqueue_style( 'twentyfifteen-style', get_stylesheet_uri() );
// hooks into wp_footer();
wp_enqueue_script( 'twentyfifteen-script', get_template_directory_uri() . '/js/functions.js',
array( 'jquery' ), '20150330', true );
}
add_action( 'wp_enqueue_scripts', 'twentyfifteen_scripts' );
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<?php wp_head(); ?>
</head>
<?php wp_footer(); ?>
</body>
</html>
// header.php
// footer.php
hooks
power of hooks
• two types: actions and filters
• part of the plugin api
• gives the ability to customize, extend, and enhance
WordPress
• used heavily throughout WordPress, plugins and themes
filters
http://codex.wordpress.org/Plugin_API/Filter_Reference
filter hook info
• Use when you want to manipulate data coming from the
database to the browser, or vice versa
• Change the content by adjusting what is outputted
• Filtered content is always returned
http://codex.wordpress.org/Plugin_API/Filter_Reference
filter hooks
add_filter( 'the_content', 'theme_add_call_number' );
function theme_add_call_number ( $content ) {
if ( is_page() ) {
$content .= '<div>Call for more info! - 555-555-5555</div>';
}
return $content;
}
// functions.php
actions
http://codex.wordpress.org/Plugin_API/Action_Reference
action hook info
• when queries are ran, actions (hooks in general) are
executed during the WordPress page creation life cycle.
• we can hook into when these are ran and run our own
functions
http://codex.wordpress.org/Plugin_API/Action_Reference
action hooks
<body>
<?php do_action ( ‘themename_before_header' ); ?>
add_action( 'themename_before_header', ‘themename_page_alert’, 5 );
function themename_page_alert() {
if ( is_front_page() ) {
echo ‘<div>Alert! We have an important message!</div>’;
}
}
// header.php
// functions.php
Local Development Crash Course
Warp Level
MAMP
or Wamp, Xampp, DesktopServer, etc
Using MAMP
• Download and install the software

- https://www.mamp.info/en/downloads/
• Setup your document root 

- where your sites will be stored
• Start the Mamp Server, create database
• Install WordPress, connect database
• Profit $$$$
https://codex.wordpress.org/Installing_WordPress_Locally_on_Your_Mac_With_MAMP
startutorial.com
“First, solve the problem. Then, write the code.”
Justin Tucker
@certainstrings certainstrings.com
resources
• developer.wordpress.org/themes/basics
• developer.wordpress.org
• wordpress.tv
• teamtreehouse.com
• pippinsplugins.com
• tommcfarlin.com
slides: bit.ly/wp-theme-building

More Related Content

What's hot

Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) Theming
PINGV
 
Rebrand WordPress Admin
Rebrand WordPress AdminRebrand WordPress Admin
Rebrand WordPress Admin
Chandra Prakash Thapa
 
Cms & wordpress theme development 2011
Cms & wordpress theme development 2011Cms & wordpress theme development 2011
Cms & wordpress theme development 2011
Dave Wallace
 
WordPress Theme Workshop: Part 2
WordPress Theme Workshop: Part 2WordPress Theme Workshop: Part 2
WordPress Theme Workshop: Part 2
David Bisset
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
Amanda Giles
 
Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016
David Brattoli
 
WordPress and PHP - It Takes One to Know One
WordPress and PHP - It Takes One to Know OneWordPress and PHP - It Takes One to Know One
WordPress and PHP - It Takes One to Know One
Lorelle VanFossen
 
WordPress Theme Development
 WordPress Theme Development WordPress Theme Development
WordPress Theme Development
Bijay Oli
 
Drupal Theme Development
Drupal Theme DevelopmentDrupal Theme Development
Drupal Theme Development
Web Development Montreal
 
Starting WordPress Theme Review
Starting WordPress Theme ReviewStarting WordPress Theme Review
Starting WordPress Theme Review
Catch Themes
 
How to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public ReleaseHow to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public Release
David Yeiser
 
WordPress Theme Development Basics
WordPress Theme Development BasicsWordPress Theme Development Basics
WordPress Theme Development Basics
Tech Liminal
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011
Ryan Price
 
Drupal 7 Theme System
Drupal 7 Theme SystemDrupal 7 Theme System
Drupal 7 Theme System
Peter Arato
 
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Emma Jane Hogbin Westby
 
Build a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ TelerikBuild a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ Telerik
Mario Peshev
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress Themes
Laura Hartwig
 

What's hot (17)

Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) Theming
 
Rebrand WordPress Admin
Rebrand WordPress AdminRebrand WordPress Admin
Rebrand WordPress Admin
 
Cms & wordpress theme development 2011
Cms & wordpress theme development 2011Cms & wordpress theme development 2011
Cms & wordpress theme development 2011
 
WordPress Theme Workshop: Part 2
WordPress Theme Workshop: Part 2WordPress Theme Workshop: Part 2
WordPress Theme Workshop: Part 2
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016Responsive themeworkshop wcneo2016
Responsive themeworkshop wcneo2016
 
WordPress and PHP - It Takes One to Know One
WordPress and PHP - It Takes One to Know OneWordPress and PHP - It Takes One to Know One
WordPress and PHP - It Takes One to Know One
 
WordPress Theme Development
 WordPress Theme Development WordPress Theme Development
WordPress Theme Development
 
Drupal Theme Development
Drupal Theme DevelopmentDrupal Theme Development
Drupal Theme Development
 
Starting WordPress Theme Review
Starting WordPress Theme ReviewStarting WordPress Theme Review
Starting WordPress Theme Review
 
How to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public ReleaseHow to Prepare a WordPress Theme for Public Release
How to Prepare a WordPress Theme for Public Release
 
WordPress Theme Development Basics
WordPress Theme Development BasicsWordPress Theme Development Basics
WordPress Theme Development Basics
 
Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011Drupal Theme Development - DrupalCon Chicago 2011
Drupal Theme Development - DrupalCon Chicago 2011
 
Drupal 7 Theme System
Drupal 7 Theme SystemDrupal 7 Theme System
Drupal 7 Theme System
 
Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010Intro to Theming Drupal, FOSSLC Summer Camp 2010
Intro to Theming Drupal, FOSSLC Summer Camp 2010
 
Build a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ TelerikBuild a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ Telerik
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress Themes
 

Viewers also liked

Creating and Managing Content on Your WordPress Site
Creating and Managing Content on Your WordPress SiteCreating and Managing Content on Your WordPress Site
Creating and Managing Content on Your WordPress SiteKelly Henderson
 
Cómo crear plugins para Wordpress
Cómo crear plugins para WordpressCómo crear plugins para Wordpress
Cómo crear plugins para Wordpress
ralcocer
 
Using Curated Content in WordPress - Why and How
Using Curated Content in WordPress - Why and HowUsing Curated Content in WordPress - Why and How
Using Curated Content in WordPress - Why and How
Adam W. Warner
 
Adventures in Non-Profit Web Design
Adventures in Non-Profit Web DesignAdventures in Non-Profit Web Design
Adventures in Non-Profit Web Design
Melodie Laylor
 
L’ascesa della geolocalizzazione. Perché mapperemo sempre di più e come lo fa...
L’ascesa della geolocalizzazione. Perché mapperemo sempre di più e come lo fa...L’ascesa della geolocalizzazione. Perché mapperemo sempre di più e come lo fa...
L’ascesa della geolocalizzazione. Perché mapperemo sempre di più e come lo fa...GGDBologna
 
WordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressWordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPress
mtoppa
 
Take the next step with git
Take the next step with gitTake the next step with git
Take the next step with git
Karin Taliga
 
Future of WordPress in Nashville 2013
Future of WordPress in Nashville 2013Future of WordPress in Nashville 2013
Future of WordPress in Nashville 2013
John Housholder
 
Wcto2012- after the install
Wcto2012- after the install Wcto2012- after the install
Wcto2012- after the install Al Davis
 
Understanding WordPress Filters and Actions
Understanding WordPress Filters and ActionsUnderstanding WordPress Filters and Actions
Understanding WordPress Filters and Actions
Ian Wilson
 
Slowcooked wp
Slowcooked wpSlowcooked wp
Slowcooked wpjoshfeck
 
WordPress End-User Security - WordCamp Las Vegas 2011
WordPress End-User Security - WordCamp Las Vegas 2011WordPress End-User Security - WordCamp Las Vegas 2011
WordPress End-User Security - WordCamp Las Vegas 2011
Dre Armeda
 
WorryProof WordPress - Backup Strategies for Your Web Site
WorryProof WordPress - Backup Strategies for Your Web SiteWorryProof WordPress - Backup Strategies for Your Web Site
WorryProof WordPress - Backup Strategies for Your Web Site
Nathan Ingram
 
Ten Things You Should Know About WordPress
Ten Things You Should Know About WordPressTen Things You Should Know About WordPress
Ten Things You Should Know About WordPress
sereedmedia
 
WordPress per giornalisti freelance
WordPress per giornalisti freelance  WordPress per giornalisti freelance
WordPress per giornalisti freelance GGDBologna
 
Reduzindo Tempo de Resposta do Servidor - WordCamp BH 2014
Reduzindo Tempo de Resposta do Servidor - WordCamp BH 2014Reduzindo Tempo de Resposta do Servidor - WordCamp BH 2014
Reduzindo Tempo de Resposta do Servidor - WordCamp BH 2014Celso Fernandes
 
WordPress Community: Choose your own adventure
WordPress Community: Choose your own adventureWordPress Community: Choose your own adventure
WordPress Community: Choose your own adventure
Andrea Middleton
 
Using Theme Frameworks for rapid development and sustainability
Using Theme Frameworks for rapid development and sustainabilityUsing Theme Frameworks for rapid development and sustainability
Using Theme Frameworks for rapid development and sustainabilityJoel Norris
 
WordCamp Rio de Janeiro 2016 - Vinícius Lourenço | Lojas Virtuais Descomplica...
WordCamp Rio de Janeiro 2016 - Vinícius Lourenço | Lojas Virtuais Descomplica...WordCamp Rio de Janeiro 2016 - Vinícius Lourenço | Lojas Virtuais Descomplica...
WordCamp Rio de Janeiro 2016 - Vinícius Lourenço | Lojas Virtuais Descomplica...
Vinícius Lourenço
 
Por um wordpress mais seguro
Por um wordpress mais seguroPor um wordpress mais seguro
Por um wordpress mais seguro
Flávio Silveira
 

Viewers also liked (20)

Creating and Managing Content on Your WordPress Site
Creating and Managing Content on Your WordPress SiteCreating and Managing Content on Your WordPress Site
Creating and Managing Content on Your WordPress Site
 
Cómo crear plugins para Wordpress
Cómo crear plugins para WordpressCómo crear plugins para Wordpress
Cómo crear plugins para Wordpress
 
Using Curated Content in WordPress - Why and How
Using Curated Content in WordPress - Why and HowUsing Curated Content in WordPress - Why and How
Using Curated Content in WordPress - Why and How
 
Adventures in Non-Profit Web Design
Adventures in Non-Profit Web DesignAdventures in Non-Profit Web Design
Adventures in Non-Profit Web Design
 
L’ascesa della geolocalizzazione. Perché mapperemo sempre di più e come lo fa...
L’ascesa della geolocalizzazione. Perché mapperemo sempre di più e come lo fa...L’ascesa della geolocalizzazione. Perché mapperemo sempre di più e come lo fa...
L’ascesa della geolocalizzazione. Perché mapperemo sempre di più e come lo fa...
 
WordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPressWordCamp Nashville: Clean Code for WordPress
WordCamp Nashville: Clean Code for WordPress
 
Take the next step with git
Take the next step with gitTake the next step with git
Take the next step with git
 
Future of WordPress in Nashville 2013
Future of WordPress in Nashville 2013Future of WordPress in Nashville 2013
Future of WordPress in Nashville 2013
 
Wcto2012- after the install
Wcto2012- after the install Wcto2012- after the install
Wcto2012- after the install
 
Understanding WordPress Filters and Actions
Understanding WordPress Filters and ActionsUnderstanding WordPress Filters and Actions
Understanding WordPress Filters and Actions
 
Slowcooked wp
Slowcooked wpSlowcooked wp
Slowcooked wp
 
WordPress End-User Security - WordCamp Las Vegas 2011
WordPress End-User Security - WordCamp Las Vegas 2011WordPress End-User Security - WordCamp Las Vegas 2011
WordPress End-User Security - WordCamp Las Vegas 2011
 
WorryProof WordPress - Backup Strategies for Your Web Site
WorryProof WordPress - Backup Strategies for Your Web SiteWorryProof WordPress - Backup Strategies for Your Web Site
WorryProof WordPress - Backup Strategies for Your Web Site
 
Ten Things You Should Know About WordPress
Ten Things You Should Know About WordPressTen Things You Should Know About WordPress
Ten Things You Should Know About WordPress
 
WordPress per giornalisti freelance
WordPress per giornalisti freelance  WordPress per giornalisti freelance
WordPress per giornalisti freelance
 
Reduzindo Tempo de Resposta do Servidor - WordCamp BH 2014
Reduzindo Tempo de Resposta do Servidor - WordCamp BH 2014Reduzindo Tempo de Resposta do Servidor - WordCamp BH 2014
Reduzindo Tempo de Resposta do Servidor - WordCamp BH 2014
 
WordPress Community: Choose your own adventure
WordPress Community: Choose your own adventureWordPress Community: Choose your own adventure
WordPress Community: Choose your own adventure
 
Using Theme Frameworks for rapid development and sustainability
Using Theme Frameworks for rapid development and sustainabilityUsing Theme Frameworks for rapid development and sustainability
Using Theme Frameworks for rapid development and sustainability
 
WordCamp Rio de Janeiro 2016 - Vinícius Lourenço | Lojas Virtuais Descomplica...
WordCamp Rio de Janeiro 2016 - Vinícius Lourenço | Lojas Virtuais Descomplica...WordCamp Rio de Janeiro 2016 - Vinícius Lourenço | Lojas Virtuais Descomplica...
WordCamp Rio de Janeiro 2016 - Vinícius Lourenço | Lojas Virtuais Descomplica...
 
Por um wordpress mais seguro
Por um wordpress mais seguroPor um wordpress mais seguro
Por um wordpress mais seguro
 

Similar to Builing a WordPress Theme

Word press templates
Word press templatesWord press templates
Word press templatesDan Phiffer
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme development
Thad Allender
 
WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3
David Bisset
 
Wordpress Custom Child theme
Wordpress Custom Child themeWordpress Custom Child theme
Wordpress Custom Child themeYouSaf HasSan
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPress
Nile Flores
 
WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4
David Bisset
 
How does get template part works in twenty ten theme
How does get template part works in twenty ten themeHow does get template part works in twenty ten theme
How does get template part works in twenty ten thememohd rozani abd ghani
 
Creating Themes
Creating ThemesCreating Themes
Creating Themes
DaisyOlsen
 
Anatomy of a Wordpress theme
Anatomy of a Wordpress themeAnatomy of a Wordpress theme
Anatomy of a Wordpress theme
Dave Wallace
 
WordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute WorkshopWordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute Workshop
Brendan Sera-Shriar
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
LinnAlexandra
 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
Chandra Prakash Thapa
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
Amanda Giles
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme development
Naeem Junejo
 
WordPress theme template tour
WordPress theme template tourWordPress theme template tour
WordPress theme template tour
Jonathan Bossenger
 
Introduction to Wordpress
Introduction to WordpressIntroduction to Wordpress
Introduction to Wordpress
Md Farhad Hussain mun
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress theme
Hardeep Asrani
 
Get Involved with WordPress
Get Involved with WordPressGet Involved with WordPress
Get Involved with WordPress
Mario Peshev
 
Introduction to Custom WordPress Themeing
Introduction to Custom WordPress ThemeingIntroduction to Custom WordPress Themeing
Introduction to Custom WordPress Themeing
Jamie Schmid
 
Building a WordPress theme
Building a WordPress themeBuilding a WordPress theme
Building a WordPress theme
Josh Lee
 

Similar to Builing a WordPress Theme (20)

Word press templates
Word press templatesWord press templates
Word press templates
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme development
 
WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3
 
Wordpress Custom Child theme
Wordpress Custom Child themeWordpress Custom Child theme
Wordpress Custom Child theme
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPress
 
WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4
 
How does get template part works in twenty ten theme
How does get template part works in twenty ten themeHow does get template part works in twenty ten theme
How does get template part works in twenty ten theme
 
Creating Themes
Creating ThemesCreating Themes
Creating Themes
 
Anatomy of a Wordpress theme
Anatomy of a Wordpress themeAnatomy of a Wordpress theme
Anatomy of a Wordpress theme
 
WordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute WorkshopWordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute Workshop
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme development
 
WordPress theme template tour
WordPress theme template tourWordPress theme template tour
WordPress theme template tour
 
Introduction to Wordpress
Introduction to WordpressIntroduction to Wordpress
Introduction to Wordpress
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress theme
 
Get Involved with WordPress
Get Involved with WordPressGet Involved with WordPress
Get Involved with WordPress
 
Introduction to Custom WordPress Themeing
Introduction to Custom WordPress ThemeingIntroduction to Custom WordPress Themeing
Introduction to Custom WordPress Themeing
 
Building a WordPress theme
Building a WordPress themeBuilding a WordPress theme
Building a WordPress theme
 

Recently uploaded

Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 

Recently uploaded (20)

Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 

Builing a WordPress Theme

  • 5. why build a theme? • better understanding of how WordPress works • self-sufficiency to fix or change theme aspects • empowerment ( yourself, a career ) • move beyond the WordPress dashboard • world domination…results may vary
  • 7. template terminology • template files - files that control how your site content is displayed • template tags - WordPress functions that grab content from the database (get_header, get_sidebar(‘someparameter’)) • page templates - type of template that is only applied to pages in your theme
  • 8. • files to display your data - WordPress template files (php) • files for theme information and styles - style.css • files to add/remove functionality (functions.php) • other files used can include javascript, images, svg, sass/less and more! theme files
  • 9. index.phpstyle.css Required Theme Files create a folder, place these two files and you’ll soon have your theme
  • 10. style.css • file header - provides details about theme in the form of comments • can house css styles for your site
  • 11. style.css /* Theme Name: Twenty Fifteen Theme URI: https://wordpress.org/themes/twentyfifteen/ Author: the WordPress team Author URI: https://wordpress.org/ Description: Our 2015 default theme is clean, blog-focused, and designed for clarity. Twenty Fifteen's simple, straightforward typography is readable on a wide variety of screen sizes, and suitable for multiple languages. Version: 1.1 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Tags: black, blue, gray, pink, purple, white, yellow, dark, light, two-columns, left-sidebar,featured-images, microformats, post-formats Text Domain: twentyfifteen` */
  • 12. Dashboard - Theme Details
  • 13. style.css /* Theme Name: Twenty Fifteen */ // begin theme styles
  • 14. index.php https://gist.github.com/philiparthurmoore/b1f47c15d3eb2c573924 <!DOCTYPE html> <html> <head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <title><?php wp_title( '|', true, 'right' ); ?></title> <link rel="stylesheet" href="<?php echo esc_url( get_stylesheet_uri() ); ?>" type="text/css" /> <?php wp_head(); ?> </head> <body> <h1><?php bloginfo( 'name' ); ?></h1> <h2><?php bloginfo( 'description' ); ?></h2>
  • 15. index.php https://gist.github.com/philiparthurmoore/b1f47c15d3eb2c573924 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h3><?php the_title(); ?></h3> <?php the_content(); ?> <?php endwhile; ?> <?php if ( get_next_posts_link() ) { next_posts_link(); } ?> <?php if ( get_previous_posts_link() ) { previous_posts_link(); } ?> <?php else: ?> <p>No posts found. :(</p> <?php endif; ?>
  • 17. most themes include these files header.php index.php sidebar.php footer.php
  • 18. header.php <!DOCTYPE html> <html> <head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <title><?php wp_title( '|', true, 'right' ); ?></title> <link rel="stylesheet" href="<?php echo esc_url( get_stylesheet_uri() ); ?>" type="text/css" /> <?php wp_head(); ?> </head> <body> <h1><?php bloginfo( 'name' ); ?></h1> <h2><?php bloginfo( 'description' ); ?></h2>
  • 20. sidebar.php <?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?> <div id="primary-sidebar" class="primary-sidebar widget-area" role="complementary"> <?php dynamic_sidebar( 'sidebar-1' ); ?> </div><!-- #primary-sidebar --> <?php endif; ?>
  • 21. working index.php <?php get_header() ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h3><?php the_title(); ?></h3> <?php the_content(); ?> <?php endwhile; ?> <?php if ( get_next_posts_link() ) { next_posts_link(); } ?> <?php if ( get_previous_posts_link() ) { previous_posts_link(); } ?> <?php else: ?> <p>No posts found. :(</p> <?php endif; ?> <?php get_sidebar() ?> <?php get_footer() ?>
  • 24. • used to display posts, page content, comments, custom post types, custom fields • when you read about certain functions that list only working in the loop, this is where it goes • https://codex.wordpress.org/The_Loop
  • 25. Blog Archive <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php the_post_thumbnail(); ?> <?php the_excerpt(); ?> <?php endwhile; else: ?> <?php _e('Sorry, no posts matched your criteria.'); ?> <?php endif; ?>
  • 26. Individual Post <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <?php endwhile; else: ?> <?php _e('Sorry, no pages matched your criteria.'); ?> <?php endif; ?>
  • 27. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <?php endwhile; else: ?> <?php _e('Sorry, no pages matched your criteria.'); ?> <?php endif; ?>
  • 29. template tags • a piece of php code that tells WordPress “do” or “get” something • they separate the theme into smaller, more understandable, sections. • some tags can only be used in specific areas • values can be passed through tags to display specific content
  • 30. working index.php <?php get_header() ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php the_title(‘<h3>’, ‘</h3>’); ?> <?php the_content(); ?> <?php endwhile; ?> <?php if ( get_next_posts_link() ) { next_posts_link(); } ?> <?php if ( get_previous_posts_link() ) { previous_posts_link(); } ?> <?php else: ?> <p>No posts found. :(</p> <?php endif; ?> <?php get_sidebar() ?> <?php get_footer() ?>
  • 31. General collect them all: https://codex.wordpress.org/Template_Tags get_header() get_footer() get_sidebar() Author wp_list_authors() the_author() the_author_link() Bookmark wp_list_bookmarks() get_bookmark() Category Comment Link the_permalink() home_url() site_url() Post the_content() the_excerpt() the_title() Post Thumbnail the_post_thumbnail() has_post_thumbnail() Navigation wp_nav_menu() template tag categories comment_author() comment_date() get_avatar() the_category() the_tags() the_terms()
  • 33. conditionals if ( is_user_logged_in() ) { echo 'Welcome, registered user!'; } else { echo 'Welcome, visitor!'; } https://developer.wordpress.org/themes/basics/conditional-tags/ if ( is_front_page() ) { // do something }
  • 35. • Query strings (data from page links) determine which template or set of templates to display page content • Templates are selected in the order determined by the template hierarchy • If a template file cannot be matched, index.php will be used
  • 36. query string - http://example.com/ template flow front-page.php home.php page.php index.php
  • 37. query string - http://example.com/blog/category/luigi/ template flow category-luigi.php category-6.php category.php archive.php index.php
  • 38. template hierarchy http://wphierarchy.com/ - Rami Abraham, Michelle Schulp
  • 39. expanded theme header.php index.php sidebar.php footer.php 404.php single.php page.php
  • 40. page templates • only apply to pages • used to change the look and feel of a page • can be applied to a single page, page section or class of pages • custom pages with template names give users control by enabling template switching
  • 41. page template flow $custom.php page-$slug.php page-id.php page.php page query
  • 42. Custom Page Template /** * Template Name: Two Columns Template * * Description: A page template that provides a key component of WordPress as * a CMS by meeting the need for a carefully crafted introductory page. * * @package WordPress * @subpackage Twenty_Fifteen * @since Twenty Fifteen 1.0 */
  • 44. folder setup • main theme template files are in the root directory • no required folders in themes at this time • page-templates folder, languages folder are auto recognized
  • 45. archive.php comments.php image.php content.php index.php page.php header.php sidebar.php screenshot.png search.php single.php style.css footer.php css inc images languages page- templates Twenty Fifteen Theme Structure 404.php author-bio.php content-*.php functions.php rtl.css
  • 47. functions file • adds/removes features and functionality to your theme • acts like a plugin • automatically loaded for both admin and external pages • “put it in your functions file” location
  • 48. • enqueuing stylesheets and scripts • enable theme features, including: sidebars, post formats, custom headers/backgrounds • enable options for the theme customizer • define functions for your theme to use • and more
  • 49. functions.php if ( ! function_exists( 'themename_setup' ) ) : function themename_setup() { register_nav_menus( array( 'primary' => __( 'Primary Menu', 'theme_name' ), 'secondary' => __( 'Secondary Menu', 'theme_name' ) ) ); add_theme_support( 'post-thumbnails' ); }
 endif; add_action( 'after_setup_theme', 'themename_setup' );
  • 50. header.php <!DOCTYPE html> <html> <head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <title><?php wp_title( '|', true, 'right' ); ?></title> <link rel="stylesheet" href="<?php echo esc_url( get_stylesheet_uri() ); ?>" type="text/css" /> <?php wp_head(); ?> </head> <body> <h1><?php bloginfo( 'name' ); ?></h1> <h2><?php bloginfo( 'description' ); ?></h2>
  • 51. functions.php function twentyfifteen_scripts() { // Load our main stylesheet. // hooks into wp_head(); wp_enqueue_style( 'twentyfifteen-style', get_stylesheet_uri() ); // hooks into wp_footer(); wp_enqueue_script( 'twentyfifteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150330', true ); } add_action( 'wp_enqueue_scripts', 'twentyfifteen_scripts' );
  • 52. <head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <title><?php wp_title( '|', true, 'right' ); ?></title> <?php wp_head(); ?> </head> <?php wp_footer(); ?> </body> </html> // header.php // footer.php
  • 53. hooks
  • 54. power of hooks • two types: actions and filters • part of the plugin api • gives the ability to customize, extend, and enhance WordPress • used heavily throughout WordPress, plugins and themes
  • 56. filter hook info • Use when you want to manipulate data coming from the database to the browser, or vice versa • Change the content by adjusting what is outputted • Filtered content is always returned http://codex.wordpress.org/Plugin_API/Filter_Reference
  • 57. filter hooks add_filter( 'the_content', 'theme_add_call_number' ); function theme_add_call_number ( $content ) { if ( is_page() ) { $content .= '<div>Call for more info! - 555-555-5555</div>'; } return $content; } // functions.php
  • 59. action hook info • when queries are ran, actions (hooks in general) are executed during the WordPress page creation life cycle. • we can hook into when these are ran and run our own functions http://codex.wordpress.org/Plugin_API/Action_Reference
  • 60. action hooks <body> <?php do_action ( ‘themename_before_header' ); ?> add_action( 'themename_before_header', ‘themename_page_alert’, 5 ); function themename_page_alert() { if ( is_front_page() ) { echo ‘<div>Alert! We have an important message!</div>’; } } // header.php // functions.php
  • 61. Local Development Crash Course Warp Level
  • 62. MAMP or Wamp, Xampp, DesktopServer, etc
  • 63. Using MAMP • Download and install the software
 - https://www.mamp.info/en/downloads/ • Setup your document root 
 - where your sites will be stored • Start the Mamp Server, create database • Install WordPress, connect database • Profit $$$$ https://codex.wordpress.org/Installing_WordPress_Locally_on_Your_Mac_With_MAMP
  • 64. startutorial.com “First, solve the problem. Then, write the code.”
  • 65. Justin Tucker @certainstrings certainstrings.com resources • developer.wordpress.org/themes/basics • developer.wordpress.org • wordpress.tv • teamtreehouse.com • pippinsplugins.com • tommcfarlin.com slides: bit.ly/wp-theme-building