SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
WordPress templates
How the content you put into wp-admin gets
          turned into web pages
What are WordPress
templates?

• Individual PHP files in a theme that
  you can modify

• Any given page request selects a
  particular template

• A child theme inherits (and overrides)
  the templates of its parent
A basic template
<?php

// Includes header.php
get_header();

// Content goes here

// Includes sidebar.php
get_sidebar();

// Includes footer.php
get_footer();

?>
header.php


<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type"
          content="text/html; charset=utf-8" />
    <title><?php bloginfo('name'); ?></title>
    <?php wp_head(); ?>
  </head>
  <body>
footer.php



    <?php wp_footer(); ?>
  </body>
</html>
functions.php


<?php

// This is where helper functions and miscellaneous
// theme settings go

// We can leave this empty for now

?>
sidebar.php


<?php

// This can also be empty

?>
What kind of content?


• Group of posts
• Single post or page
• Media attachment
Groups of posts


• Most recent posts (index.php)
• Posts in a specific category
  (category.php)

• Search results (search.php)
The loop

“ The Loop is used by WordPress to display each
  of your posts. Using The Loop, WordPress
  processes each of the posts to be displayed on
  the current page and formats them according to
  how they match specified criteria within The
  Loop tags. Any HTML or PHP code placed in
  the Loop will be repeated on each post.”
 —WordPress Codex
A basic WordPress loop

<?php

while (have_posts()) {
  the_post();
  // Display post content
}

?>
A more sophisticated loop,
with error checking
<?php

if (have_posts()) {
  while (have_posts()) {
    the_post();
    // Display post content
  }
} else {
  echo "Sorry, no posts were found.n";
}

?>
How do you display post
content?

• Template Tags are pre-written helper
  functions you can use in your theme

• For example the_title() which
  prints out the current post’s title

• They are documented extensively
Using template tags
<?php

while (have_posts() {
  the_post();

?>
<div id="<?php the_ID(); ?>">
   <h1><?php the_title(); ?></h1>
   <div class="content"><?php the_content(); ?></div>
   Posted on <?php the_data(); ?>
   at <?php the_time(); ?>
</div>
<?php

}

?>
Template hierarchy
index.php       home.php         date.php

                front-page.php   author.php

                404.php          category.php

header.php      search.php       tag.php

footer.php      archive.php      taxonomy.php

functions.php   single.php       attachment.php

                page.php         custom.php

Mais conteúdo relacionado

Mais procurados

Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themesDaisyOlsen
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress ThemesLaura Hartwig
 
WCLV - Introduction to child themes
WCLV - Introduction to child themesWCLV - Introduction to child themes
WCLV - Introduction to child themesvegasgeek
 
Drupal 7 Theming - what's new
Drupal 7 Theming - what's newDrupal 7 Theming - what's new
Drupal 7 Theming - what's newMarek Sotak
 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - LondonMarek Sotak
 
Choosing Themes
Choosing ThemesChoosing Themes
Choosing ThemesDaisyOlsen
 
Adopt or hack - how to hack a theme in a Drupal way
Adopt or hack - how to hack a theme in a Drupal wayAdopt or hack - how to hack a theme in a Drupal way
Adopt or hack - how to hack a theme in a Drupal wayMarek Sotak
 
Theme like a monster #ddceu
Theme like a monster #ddceuTheme like a monster #ddceu
Theme like a monster #ddceuMarek Sotak
 
WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3David Bisset
 
Atomicant Drupal 6 Theming
Atomicant Drupal 6 ThemingAtomicant Drupal 6 Theming
Atomicant Drupal 6 ThemingMarek Sotak
 
Arizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress ThemeArizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress Themecertainstrings
 
Streamlining Your Template Structures When Building Themes
Streamlining Your Template Structures When Building ThemesStreamlining Your Template Structures When Building Themes
Streamlining Your Template Structures When Building ThemesCameron Jones
 
Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themesDaisyOlsen
 
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp..."Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...Sudeep Balchhaudi
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1Yoav Farhi
 
Converting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeConverting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeAdolfo Nasol
 
Installing And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blogInstalling And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blogigorgentry
 
Cms & wordpress theme development 2011
Cms & wordpress theme development 2011Cms & wordpress theme development 2011
Cms & wordpress theme development 2011Dave Wallace
 

Mais procurados (20)

Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themes
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress Themes
 
WCLV - Introduction to child themes
WCLV - Introduction to child themesWCLV - Introduction to child themes
WCLV - Introduction to child themes
 
Drupal 7 Theming - what's new
Drupal 7 Theming - what's newDrupal 7 Theming - what's new
Drupal 7 Theming - what's new
 
Drupal
DrupalDrupal
Drupal
 
D7 theming what's new - London
D7 theming what's new - LondonD7 theming what's new - London
D7 theming what's new - London
 
Choosing Themes
Choosing ThemesChoosing Themes
Choosing Themes
 
Adopt or hack - how to hack a theme in a Drupal way
Adopt or hack - how to hack a theme in a Drupal wayAdopt or hack - how to hack a theme in a Drupal way
Adopt or hack - how to hack a theme in a Drupal way
 
Theme like a monster #ddceu
Theme like a monster #ddceuTheme like a monster #ddceu
Theme like a monster #ddceu
 
WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3
 
Atomicant Drupal 6 Theming
Atomicant Drupal 6 ThemingAtomicant Drupal 6 Theming
Atomicant Drupal 6 Theming
 
Arizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress ThemeArizona WP - Building a WordPress Theme
Arizona WP - Building a WordPress Theme
 
Streamlining Your Template Structures When Building Themes
Streamlining Your Template Structures When Building ThemesStreamlining Your Template Structures When Building Themes
Streamlining Your Template Structures When Building Themes
 
Meetup child-themes
Meetup child-themesMeetup child-themes
Meetup child-themes
 
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp..."Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
 
WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1WordPress Developers Israel Meetup #1
WordPress Developers Israel Meetup #1
 
Converting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 ThemeConverting (X)HTML/CSS template to Drupal 7 Theme
Converting (X)HTML/CSS template to Drupal 7 Theme
 
Theming 101
Theming 101Theming 101
Theming 101
 
Installing And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blogInstalling And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blog
 
Cms & wordpress theme development 2011
Cms & wordpress theme development 2011Cms & wordpress theme development 2011
Cms & wordpress theme development 2011
 

Semelhante a Word press templates

Builing a WordPress Theme
Builing a WordPress ThemeBuiling a WordPress Theme
Builing a WordPress Themecertainstrings
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPressNile Flores
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme EnlightenmentAmanda Giles
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017Amanda Giles
 
Creating Themes
Creating ThemesCreating Themes
Creating ThemesDaisyOlsen
 
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
 
Wordpress Custom Child theme
Wordpress Custom Child themeWordpress Custom Child theme
Wordpress Custom Child themeYouSaf HasSan
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentSitdhibong Laokok
 
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
 
Grok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateGrok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateLaura Scott
 
WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4David Bisset
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress themeHardeep Asrani
 
Various Ways of Using WordPress
Various Ways of Using WordPressVarious Ways of Using WordPress
Various Ways of Using WordPressNick La
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme developmentThad Allender
 
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 WorkshopBrendan Sera-Shriar
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 
Your First Wordpress Theme
Your First Wordpress ThemeYour First Wordpress Theme
Your First Wordpress Themesayed fathey
 

Semelhante a Word press templates (20)

Builing a WordPress Theme
Builing a WordPress ThemeBuiling a WordPress Theme
Builing a WordPress Theme
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPress
 
Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)Wordpress(css,php,js,ajax)
Wordpress(css,php,js,ajax)
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
Creating Themes
Creating ThemesCreating Themes
Creating Themes
 
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
 
Wordpress Custom Child theme
Wordpress Custom Child themeWordpress Custom Child theme
Wordpress Custom Child theme
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme Development
 
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 ...
 
Grok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateGrok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb update
 
WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4WordPress Theme Workshop: Part 4
WordPress Theme Workshop: Part 4
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress theme
 
Various Ways of Using WordPress
Various Ways of Using WordPressVarious Ways of Using WordPress
Various Ways of Using WordPress
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme development
 
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
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
WordPress Theming 101
WordPress Theming 101WordPress Theming 101
WordPress Theming 101
 
20110820 header new style
20110820 header new style20110820 header new style
20110820 header new style
 
Your First Wordpress Theme
Your First Wordpress ThemeYour First Wordpress Theme
Your First Wordpress Theme
 

Mais de Dan Phiffer

Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptDan Phiffer
 
Static layouts with css
Static layouts with cssStatic layouts with css
Static layouts with cssDan Phiffer
 
Intro to word press
Intro to word pressIntro to word press
Intro to word pressDan Phiffer
 

Mais de Dan Phiffer (7)

Occupy.here
Occupy.hereOccupy.here
Occupy.here
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Static layouts with css
Static layouts with cssStatic layouts with css
Static layouts with css
 
Intro to word press
Intro to word pressIntro to word press
Intro to word press
 
Diving into php
Diving into phpDiving into php
Diving into php
 
The web context
The web contextThe web context
The web context
 
Web tech 101
Web tech 101Web tech 101
Web tech 101
 

Word press templates

  • 1. WordPress templates How the content you put into wp-admin gets turned into web pages
  • 2. What are WordPress templates? • Individual PHP files in a theme that you can modify • Any given page request selects a particular template • A child theme inherits (and overrides) the templates of its parent
  • 3. A basic template <?php // Includes header.php get_header(); // Content goes here // Includes sidebar.php get_sidebar(); // Includes footer.php get_footer(); ?>
  • 4. header.php <!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title><?php bloginfo('name'); ?></title> <?php wp_head(); ?> </head> <body>
  • 5. footer.php <?php wp_footer(); ?> </body> </html>
  • 6. functions.php <?php // This is where helper functions and miscellaneous // theme settings go // We can leave this empty for now ?>
  • 7. sidebar.php <?php // This can also be empty ?>
  • 8. What kind of content? • Group of posts • Single post or page • Media attachment
  • 9. Groups of posts • Most recent posts (index.php) • Posts in a specific category (category.php) • Search results (search.php)
  • 10. The loop “ The Loop is used by WordPress to display each of your posts. Using The Loop, WordPress processes each of the posts to be displayed on the current page and formats them according to how they match specified criteria within The Loop tags. Any HTML or PHP code placed in the Loop will be repeated on each post.” —WordPress Codex
  • 11. A basic WordPress loop <?php while (have_posts()) { the_post(); // Display post content } ?>
  • 12. A more sophisticated loop, with error checking <?php if (have_posts()) { while (have_posts()) { the_post(); // Display post content } } else { echo "Sorry, no posts were found.n"; } ?>
  • 13. How do you display post content? • Template Tags are pre-written helper functions you can use in your theme • For example the_title() which prints out the current post’s title • They are documented extensively
  • 14. Using template tags <?php while (have_posts() { the_post(); ?> <div id="<?php the_ID(); ?>"> <h1><?php the_title(); ?></h1> <div class="content"><?php the_content(); ?></div> Posted on <?php the_data(); ?> at <?php the_time(); ?> </div> <?php } ?>
  • 15.
  • 16.
  • 17. Template hierarchy index.php home.php date.php front-page.php author.php 404.php category.php header.php search.php tag.php footer.php archive.php taxonomy.php functions.php single.php attachment.php page.php custom.php