Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WordPress テーマ作成超入門

WordPress テーマ作成超入門

@WordBench Nagoya 201806

How-to-create-wp-theme-firststep-WBN201806

RyoUozumi

June 09, 2018
Tweet

More Decks by RyoUozumi

Other Decks in Technology

Transcript

  1. • index.php ౔୆ͷςϯϓϨʔτϑΝΠϧ • archive.php ΞʔΧΠϒϖʔδΛදࣔ͢ΔςϯϓϨʔτϑΝΠϧ • single.php ݸผ౤ߘϖʔδΛදࣔ͢ΔςϯϓϨʔτϑΝΠϧ •

    page.php ݻఆϖʔδΛදࣔ͢ΔςϯϓϨʔτϑΝΠϧ • front-page.php αΠτϑϩϯτϖʔδΛදࣔ͢ΔςϯϓϨʔτϑΝΠϧ • sidebar.php αΠυόʔΛදࣔ͢ΔςϯϓϨʔτϑΝΠϧ • header.php <?php get_header(); ?> ͷத਎ • footer.php <?php get_footer(); ?> ͷத਎ • functions.php ςʔϚͷػೳʢϓϥάΠϯͱಉ͜͡ͱ͕Ͱ͖Δʣ

  2. STYLE.CSSΛॻ͍ͯΈΑ͏ /* Theme Name: ςʔϚͷ໊લ Theme URI: ςʔϚͷαΠτ Description: ςʔϚͷઆ໌

    Version: 0.1 όʔδϣϯ1ʹͯ͠(׬੒ͤͯ͞)ެ։͠Α͏ʂ Author: WBN ࣗ෼ͷ໊લΛ஌Β͠ΊΕΔ Author URI: ࣗ෼ͷαΠτ License: GNU General Public License v2 or later */ •
  3. ςʔϚΛ࡞੒͢Δલʹ • <?php get_header(); ?> • header.phpΛಡΈࠐΉ • <?php get_sidebar();

    ?> • sidebar.phpΛಡΈࠐΉ • <?php get_footer(); ?> • footer.phpΛಡΈࠐΉ
  4. Τεέʔϓॲཧ • Τεέʔϓॲཧͷඞཁੑ • ΋͠URLʹ༗֐ͳϦϯΫΛೖྗ͞Εͯ΋ɺແ֐ԽͰ͖ɺXSSΛ๷ࢭͰ͖Δ • <?php echo esc_url( home_url(

    '/' ) ); ?> • ྫ:<script>ѱ͍.js</script> • ݕࡧཝ΍ίϝϯτཝʹ͔͔Εͯ΋ • &lt;script&gt;ѱ͍.js&lt;/script&gt; • ͱͳΓѱ͍Javascript͕ແޮԽ͞ΕΔ •
  5. HEADER.PHPΛॻ͍ͯΈΑ͏ • <!DOCTYPE html> • <html <?php language_attributes(); ?> •

    <head> • <meta charset="<?php bloginfo( 'charset' ); ?>”> • <?php wp_head(); ?> • </head>
  6. SINGLE.PHPΛॻ͍ͯΈΑ͏ • while ( have_posts() ) : • the_post(); •

    the_post_navigation(); • comments_template();
  7. FUNTIODNS.PHP 2 • CSS΍jsͳͲΛfunctions.phpͰ؅ཧ͍ͨ͠৔߹ • function wbn_scripts() { • wp_enqueue_style(

    'wbn-style', get_stylesheet_uri() ); • wp_enqueue_script( 'wbn-navigation', get_template_directory_uri() . '/js/ navigation.js', array(), '20151215', true ); • wp_enqueue_script( 'wbn-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
  8. FUNCTIONS.PHP 3 • ઌ΄Ͳ࡞ͬͨαΠυόʔΛfuntions.phpʹొ࿥ • function wbn_widgets_init() { • register_sidebar(

    array( • 'name' => esc_html__( 'Sidebar', 'wbn' ), • 'id' => 'sidebar-1', • 'description' => esc_html__( 'Add widgets here.', 'wbn' ), • 'before_widget' => '<section id="%1$s" class="widget %2$s">', • 'after_widget' => '</section>', • 'before_title' => '<h2 class="widget-title">', • 'after_title' => '</h2>', • ) );