WordPressテーマの編集

WordPressテーマの編集

これは、元のファイルに手を加えずにバックアップファイル(子テーマとして表現)を修正して使用する方法です。

  1. 使用している子テーマを簡単に確認できるように、テーマ名を組み合わせて「wp-content/themes」フォルダに新しいフォルダを作成します。(例:元のテーマが「twentyfifteen」の場合、「twentyfifteen-child」というフォルダを作成)
  2. 元のテーマの「style.css」を子テーマフォルダにコピーし、「Theme Name」と「Template」を以下のように修正します。
    /*
    Theme Name: Twenty Fifteen Child
    Theme URI: https://wordpress.org/themes/twentyfifteen/
    Template: twentyfifteen
    Author: the WordPress team
    Author URI: https://wordpress.org/
    Description: 2015年のデフォルトテーマはクリーンでブログに焦点を当てたもので、明快さを追求しています。Twenty Fifteenのシンプルでストレートフォワードなタイポグラフィは、さまざまな画面サイズで読みやすく、多言語に適しています。モバイルファーストアプローチで設計されているため、訪問者がスマートフォン、タブレット、ノートパソコン、またはデスクトップコンピュータでアクセスしても、コンテンツが中心になります。
    Version: 1.5
    License: GNU General Public License v2 or later
    License URI: http://www.gnu.org/licenses/gpl-2.0.html
    Tags: black, blue, gray, pink, purple, white, yellow, dark, light, two-columns, left-sidebar, fixed-layout, responsive-layout, accessibility-ready, custom-background, custom-colors, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready
    Text Domain: twentyfifteenTemplate: twntyfifteen
    このテーマは、WordPressと同様にGPLの下でライセンスされています。
    クールなものを作成し、楽しんで学んだことを他の人と共有してください。
    */
    
  3. 子テーマフォルダに「functions.php」を以下のコードで作成します。
    <?php
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    ?>
    
  4. 元のテーマの「screenshot.png」を子テーマフォルダにコピーします。
  5. 元のテーマのファイルを子テーマフォルダにコピーした後、必要に応じて修正して使用することができます。

(参考 : http://codex.wordpress.org/Child_Themes)

Leave a Reply

이메일 주소는 공개되지 않습니다. (* 질문, 건의사항 등은 "질문게시판"을 이용해주세요)