WordPress3.0 新デフォルトテーマ Twenty Ten 大解剖!

82
1/82 WordPress3.0 新デフォルトテーマ Twenty Ten 大解剖! 2010年8月21日 WordBench Nagoya 松下 寛子@hokori

description

WordPress3.0から新しいデフォルトテーマになった、Twenty Ten についての解説のスライドです。 テンプレートの基礎、Twenty Tenのコード、子テーマについて記載されています。 2010年8月21日に開催された、WordBench名古屋で発表しました。

Transcript of WordPress3.0 新デフォルトテーマ Twenty Ten 大解剖!

  • 1/82

    WordPress3.0

    Twenty Ten

    2010821WordBench Nagoya

    @hokori

  • 2/82

    @hokorihttp://hokori.net/

    SEDTPWEB

    OSC Nagoya 2010

  • 3/82

    WordPress Twenty Ten Twenty Ten

  • 4/82

    WordPress

  • 5/82

    WordPress (1)WordPress wp-content/themes/ Twenty Ten wp-content/themes/twentyten

    WordPress3 1. style.css 2. functions.php 3.

  • 6/82

    WordPress (2)1. style.css

    2. functions.phpPHP

    3. PHP

  • 7/82

    index.php home.php single.php page.php category.phpetc

    header.php sidebar.php footer.php loop.php comments.phpetc

  • 8/82

    WordPress (1)WordPress

    1. category-slug.php2. category-ID.php3. category.php4. archive.php5. index.php

  • 9/82http://codex.wordpress.org/images/1/18/Template_Hierarchy.png

    WordPress (2)

  • 10/82

    Twenty Ten

  • 11/82

    Twenty Ten 404.phparchive.phpattachment.phpauthor.phpcategory.phpcomments.phpeditor-style-rtl.csseditor-style.cssfooter.phpfunctions.phpheader.phpindex.phplicense.txt

    loop.phponecolumn-page.phppage.phprtl.cssscreenshot.pngsearch.phpsidebar-footer.phpsidebar.phpsingle.phpstyle.csstag.php/images/languages

  • 12/82

    WordPress 2010 -- Twenty Ten 6 (24) () "Asides" "Gallery" 1

    style.css

  • 13/82

    WordPressP3.0

  • 14/82

    21

  • 15/82

  • 16/82

  • 17/82

    editor-style.css

  • 18/82

    1214

  • 19/82

  • 20/82

  • 21/82

  • 22/82

    asides gallery

  • 23/82

  • 24/82

    2 1 21

  • 25/82

    style.css@media print

  • 26/82

    Twenty Ten

  • 27/82

    index.php5

    index.php

    header.php

    loop.php

    sidebar.php

    footer.php

    sidebar-footer.php

    index.php

  • 28/82

    index.php

  • 29/82

    01. 17. 18. 19. 20.

    index.php (1/2)

  • 30/82

    21. 28. 29. 30. 31. 32.

    index.php (2/2)

  • 31/82

    (1)get_template_partWP3.0

    slug name slug-name.php slug.php

  • 32/82

    (2)

    twentytentwentyten-child

    1. wp-content/themes/twentyten-child/loop-index.php

    2. wp-content/themes/twentyten-child/loop.php3. wp-content/themes/twentyten/loop-index.php

    4. wp-content/themes/twentyten/loop.php

  • 33/82

    header.php

  • 34/82

    01. 12.

  • 35/82

    22. 23. // Add the blog name.24. bloginfo( 'name' );25. 26. // Add the blog description for the home/front page.27. $site_description = get_bloginfo( 'description', 'display' );28. if ( $site_description && ( is_home() || is_front_page() ) )29. echo " | $site_description";30. 31. // Add a page number if necessary:32. if ( $paged >= 2 || $page >= 2 )33. echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );34. 35. ?>36. 37.

  • 36/82

    43. if ( is_singular() && get_option( 'thread_comments' ) )44. wp_enqueue_script( 'comment-reply' );45. 46. /* Always have wp_head() just before the closing 47. * tag of your theme, or you will break many plugins, which48. * generally use this hook to add elements to such49. * as styles, scripts, and meta tags.50. */51. wp_head();52. ?>53. 54. 55. 62.

  • 37/82

    esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">

    65. 66. 68. 69.

  • 38/82

    81. 82. 83. 84.

  • 39/82

  • 40/82

    (2)WP2.9functions.phpTwenty Ten

    has_post_thumbnailWP2.9 )

    get_the_post_thumbnailWP2.9 )

  • 41/82

    (3)WP3.0Twenty Ten

    header_imageWP2.1 )

  • 42/82

    wp_nav_menuWP3.0 )

    wp_page_ menu

  • 43/82

    loop.php

  • 44/82

    01. 21.

    loop.php(1/10)

  • 45/82

    22. 23. 24. 25.

  • 46/82

    41. 56. 57. 58. 59. 60. 61.

  • 47/82

    printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">

    63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 79.

    loop.php(4/10)

    Twenty Ten

  • 48/82

    80.

  • 49/82

    95.

  • 50/82

    113. 114. 115. 116. |117.

    118.

  • 51/82

    130. 131. 132. 133. 134. 135. 136. 137. 138.

  • 52/82

    147. 148. |149. 150. 154. 155.

  • 53/82

    165. 166. 167. 168. 169. 170. 171. 172. 173.

  • 54/82

    loop.php loop.php

    archive.php author.php category.php index.php loop.php search.php tag.php

    Twenty Ten loop.php

  • 55/82

    sidebar.php

  • 56/82

    01. 10. 11. 12. 13. 14.

  • 57/82

    22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43.

    sidebar.php(2/3)

    1

  • 58/82

    44. 45. 46. 49. 50. 51. 52. 53. 54. 55. 56.

    sidebar.php(3/3)

    2

  • 59/82

    WP2.2WP3.0

    Tentry Ten

    dynamic_sidebarWP2.2 )

  • 60/82

    footer.php

  • 61/82

    01. 13. 14. 15. 16. 17. 18.

  • 62/82

    23. ?>24. 25. 26.

  • 63/82

    41. 42. 43. 44. 52. 53.

    footer.php(3/3)

  • 64/82

    sidebar-footer.php

  • 65/82

    01. 10. 11.

  • 66/82

    23. // If we get this far, we have widgets. Let do this.24. ?>25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42.

    sidebar-footer.php(2/3)

    1 4

    2

  • 67/82

    43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60.

    sidebar-footer.php(3/3) 3

    4

  • 68/82

    archive.phpcategory.phptag.phpsearch.phpsingle.phppage.phponecolumn-page.php

    attachment.phpauther.php404.phpcomments.phpfunctions.php

  • 69/82

  • 70/82

    WordPress

    http://wpdocs.sourceforge.jp/Child_Themes

  • 71/82

    AB A B

    AB A A B A

  • 72/82

    (1)style.cssscreenshot.png

    wp-content

    twentyten-child

    twentyten

    themes

    style.css

    screenshot.png

  • 73/82

    (2)style.cssTemplate

    /*Theme Name: Theme URI: http://example.net/Description: Author: Version: 1.0Template: twentytenTags: hoge*/

  • 74/82

    (3)

    twentyten-child

    twentyten

    themes

    wp-content

    style.css

    screenshot.png

    loop-category.php

    category.php

    loop-index.php

  • 75/82

  • 76/82

    functions.php(1)functions.php

    functions.php functions.php

  • 77/82

    functions.php(2)

    functions.php

    206. /**207. * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.208. *209. * To override this in a child theme, remove the filter and optionally add210. * your own function tied to the wp_page_menu_args filter hook.211. *212. * @since Twenty Ten 1.0213. */214. function twentyten_page_menu_args( $args ) {

    288. if ( ! function_exists( 'twentyten_comment' ) ) :289. /**290. * Template for comments and pingbacks.291. *292. * To override this walker in a child theme without modifying the comments template293. * simply create your own twentyten_comment(), and that function will be used

    instead.294. *295. * Used as a callback by wp_list_comments() for displaying the comments.

    Twenty Ten functions.php

  • 78/82

    (1)URL

    URL bloginfo('template_directory'); http://home.matu-win-local.com/wp/wp-content/themes/twentyten

    bloginfo('stylesheet_directory')http://example.net/wp/wp-content/themes/twentyten-child

  • 79/82

    (2)

    TEMPLATEPATH/home/hoge/www/wp-content/themes/twentyten

    STYLESHEETPATH/home/hoge/www/wp-content/themes/twentyten-child

  • 80/82

    Version 3.0 - WordPress Codex http://wpdocs.sourceforge.jp/Version_3.0

    WordPress 3.0 - WordPress3.0Twenty Ten | WordPresshttp://wp3.jp/2010/06/11/wordpress3-2/

    : Twenty Ten - - WordPress.comhttp://ja.blog.wordpress.com/2010/04/27/new-theme-twenty-ten/

    TwentyTen http://www.slideshare.net/yorozu/about-twentyten-on-wordpress3

    - WordPress Codex http://wpdocs.sourceforge.jp/Child_Themes

    Duotone - Wordcamp Fukuoka 2010http://www.slideshare.net/odysseygate/duotone-wordcamp-fukuoka-2010

  • 81/82

    WordCamp Nagoya 2010 http://nagoya2010.wordcamp.jp/

  • 82/82

    @hokorihttp://hokori.net/