WordPress の機能をちゃんと知る

WordPress の機能をちゃんと知る

WordBench Nagano vol. 17 での登壇資料です

E03953e0c18d776fead147601fdc3899?s=128

Toro_Unit (Hiroshi Urabe)

March 31, 2018
Tweet

Transcript

  1. WordPress ͷػೳΛͪΌΜͱ஌Δɻ Toro_Unit @2018.03.31 / WBNagano #17 1

  2. $ whoami 2

  3. Toro_Unit ઎෦ ߛ (͏Β΂ ͻΖ͠) HAMWORKS • Frontend Engineer •

    WordPress Plugin and Theme Developer • Custom Post Type Permalinks • Vanilla • more... Github: @torounit Twitter: @Toro_Unit 3
  4. ࡳຈͷձࣾͰϦϞʔτ ϫʔΫͯ͠·͢ɻ 4

  5. Plugins and Themes • Custom Post Type Permalinks • Simple

    Post Type Permalinks • Powerful Posts Per Page (PPPP) • Responsive Slide • Vanilla • and more... 5
  6. Contribution • WordBench ௕໺ ϞσϨʔλʔ • WordCamp Kyoto 2017 ࣮ߦҕһ

    • WordCamp Tokyo 2017 Speaker • WordBench.org • VCCW Team • etc... 6
  7. WordPress ͷςʔϚ࡞ͬͯ·͔͢ʁ WordPress ͰαΠτ࡞ͬͯ·͔͢ʁ 7

  8. WordPress ͷػೳ஌ͬͯ·͔͢ʁ 8

  9. ࠓ೔ݴ͍͍ͨ͜ͱɿωοτͰरͬͨ ίʔυΛfunctions.php ʹίϐϖ͢Δ લʹߟ͑Α͏ɻ 9

  10. Case.1 ίϝϯτϑΟʔυΛফ͍ͨ͠ɻ <link rel="alternate" type="application/rss+xml" title="Toro_Unit &raquo; ϑΟʔυ" href="https://torounit.com/feed/" />

    <link rel="alternate" type="application/rss+xml" title="Toro_Unit &raquo; ίϝϯτϑΟʔυ" href="https://torounit.com/comments/feed/" /> ίϝϯτ࢖Θͳ͍͔Βফ͍ͨ͠ɻ 10
  11. remove_action( 'wp_head', 'feed_links_extra', 3 ); add_filter( 'feed_links_show_comments_feed', '__return_false'); άάΔͱ͜Μͳͷग़ͯ͘Δ͚Ͳɾɾɾ 11

  12. 12

  13. • feed_links_extra Λফ͢ͱɺίϝϯτҎ֎ͷϑΟʔυ΋ແ ͘ͳΔɻ • ࡢࠓ feed ͕ඞཁͱ͍͏৔໘͸গͳ͍Ͱ͠ΐ͏͕ɻɻɻ • link

    λάΛফͨ͠ͱ͜ΖͰɺΞΫηεͰ͖ͯ͠·͏ɻ 13
  14. • ҆қͳίϐϖΛ͢Δલʹɺ؅ཧը໘ΛோΊΔɻ • ؅ཧը໘Ͱग़དྷΔ͜ͱ͸؅ཧը໘Ͱɻ 14

  15. case.2 admin-bar Λফ͍ͨ͠ɻ 15

  16. <?php wp_footer();?> ·͔͞ɺwp_footer ফͯ͠ͳ͍ΑͶɾɾɾɻ 16

  17. • wp_head, wp_footer ͸ WordPress ΍ɺϓϥάΠϯ͕ɺCSS, ϝλλάɺJSͳͲΛग़ྗͨ͠Γ͢Δࡍʹ࢖ΘΕΔ΋ͷɻ • ίϨ͕ແ͍ςʔϚ͸ςʔϚͱͯ͠όάͬͯΔɻ 17

  18. πʔϧόʔͷ߲໨͔Βඇදࣔʹग़དྷΔɻ 18

  19. case.3 ౤ߘҰཡϖʔδ Λ࡞Δ 19

  20. <?php query_posts( array( 'post_type' => 'post', 'paged' => get_query_var('paged') )

    );?> <?php if( have_posts(): while( have_posts()) : the_post();?> <?php endwhile; endif;?> <?php wp_reset_postdata();?> <?php wp_reset_query();?> ͱ͔ <?php $blog = new WP_Query( array( 'post_type' => 'post', 'paged' => get_query_var('paged') ) );?> <?php if($blog->have_posts(): while($blog->have_posts() ): $blog->the_post();?> <?php endwhile; endif;?> <?php wp_reset_postdata();?> Ͱ࣮૷ग़དྷΔ͔΋͠Ε·ͤΜ͕ɻɻɻ 20
  21. දࣔઃఆͰઃఆͰ͖Δͧɻ ϗʔϜϖʔδʹ͸ɺfront-page.php → page.php → index.php ͷςϯϓϨʔτ͕ద༻͞ΕΔɻ ౤ߘϖʔδʹ͸ɺhome.php → index.php

    ͷॱͰςϯϓϨʔτ͕ద༻͞ΕΔɻ σϑΥϧτͷ ʮ࠷৽ͷ౤ߘʯͷ৔߹ɺfront-page.php → home.php → index.php ͷॱɻ 21
  22. ςʔϚͷ࡞Γํɻ ެࣜͷυΩϡϝϯςʔγϣϯɻࠓͷͱ͜ Ζӳޠ͔͠ແ͍͚ͲɺίʔυͰͷղઆ΋ ଟ͍ͷͰҙ֎ʹͳΜͱ͔ͳΔɻ • Theme Developer Handbook • https://developer.wordpress.org/

    themes/ 22
  23. ςʔϚϨΠϠʔͱϓϥάΠϯϨΠϠʔ • ςʔϚ͕΍ͬͯྑ͍ͷ͸ɺσβΠϯɺݟͨ໨ʹؔΘΔ͜ͱͷ Έɻ • WordPress ͷڍಈΛม͍͑ͨͱ͖͸ϓϥάΠϯͰɻ 23

  24. • ϓϥάΠϯʹ͓͍ͯͨ͠ํ͕ɺςʔϚΛม͑ͯ΋ෆ۩߹͸ແ ͍ɻ • ػೳʹ໊લΛ෇͚Δ͜ͱͰɺͦΕ͕ԿΛ͢ΔͨΊͷϞϊͳͷ ͔ʁ͕ޙ͔Β൑ผՄೳɻ 24

  25. ৘ใͷूΊํ 25

  26. • ωοτͷ৘ใ͸ۄੴࠞަɻ҆қʹඈͼ͔ͭͣɺଞͷϞϊ΋ݟΔɻ • ·ͣ͸ɺ৴པͰ͖ΔϦιʔεΛௐ΂Δɻ • ެࣜͷυΩϡϝϯςʔγϣϯ • Codex • σϑΥϧτςʔϚ

    • WordPress.org ܝࡌςʔϚ • ༗໊ͳϓϥάΠϯ/ςʔϚ࡞ऀͷίʔυɻ • forum Ͱͷղ౴ɻ/ ࣭໰ͯ͠ΈΔɻ 26
  27. ࣗ෼Ͱ৮ͬͯΈΔɻ • ·ͣ͸ࣗ෼ͰԿͰ΋͍͍͔Β৮ͬͯΈΔɻ • ࣗ෼Ͱ࢖͍ͪ͜͝ͱ͔ΛΘ͔ͬͯΔͱɺצॴͱ͔͕͔ͭΈ΍ ͍͢ɻ • ࣗ෼΋1Ϣʔβʔͱͯ͠࢖͍౗͢ɻ 27

  28. and.. Let's Join WordBench! wordbench.org 28

  29. ͓ΘΓɻ Thanks! Github: @torounit Twitter: @Toro_Unit Facebook: fb.me/torounit WEB Site:

    https://torounit.com 29