超絶初心者(自分)のためのWordPressのテーマ作成-1

プログラミング備忘録

  1. wp-contentを探し、その中のthemeファルダーに入る.
  2. themeフォルダーの中に、自分の望むテーマの名前をつけたフォルダーを作る.
  3. 今作ったフォルダーの中に、style.cssを作る.
  4. style.cssに以下の情報を記述(*自分にあったものに適宜変更).
    /*
      Theme Name:  my_theme
      Theme URI:
      Author: Takumi Aizawa
      Author URI:
      Description: This is my first theme!
      Version: 0.1 alpha
      License:
      License URI:
      Tags: black, white, responsive, two-columns, featured-images, custom-menu, custom-header, oist-formats
    */
    
  5. header.phpの作成と以下の記述
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <title>my_theme site</title>
        <?php wp_head();?>
      </head>
      <body>
    
        <?php wp_nav_menu(array('theme_location'=>'primary'));?>
  6. footer.phpを作成し、以下を記述.
    <footer>
      <p>This is footer</p>
    </footer>
    <?php wp_nav_menu(array('theme_location'=>'secondary'));?>
    <?php wp_footer();?>
    </body>
    </html>
    
  7. index.phpの作成と以下の記述.
    <?php get_header(); ?>
    <h1>This is my website</h1>
    <?php get_footer(); ?>

*get_header()でheader.phpを読み込む.

*get_footer()でfooter.phpを読み込む.

*これにより一つのhtml(php)ファイルが完結する.

 

これでとりあえずひとまずテーマとしてwordpressに読み込まれるようになります.

Posted by cabc-1234