2016-04-22 10 views
0

WordPressテーマを開発しています。カスタマイズ可能なページに色オプションを追加して、管理者が背景色、テキスト色、リンクカラーなどを変更できるようにしました。 "Akismet"を除いて私のWordPressのディレクトリにインストールされているプラ​​グインはありません。 "mytheme"(mythemeは私のテーマの名前です)を除いて、すべてのテーマはカスタマイズページでそのオプションを持っています。 私の質問は、どのように "サイト識別"オプションの直後に表示されるカスタマイズページでその色オプションを追加することができますです。このようなwordpressでカラーオプションを追加する方法

Customizer WordPress

何かが動作するはずです:: はこれを読んで、あなたに

+0

wp_head();経由のhttps:/ /wordpress.org/plugins/fourteen-colors/ –

答えて

1

ありがとう私はあなたがこのプラグインを使用すると思います

function mytheme_customize_register($wp_customize) { 
    //All our sections, settings, and controls will be added here 
    $wp_customize->add_setting('header_textcolor' , array(
     'default'  => "#000000", 
     'transport' => 'refresh', 
    )); 

    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'header_textcolor', array(
     'label'  => __('Header Color', 'mytheme'), 
     'section' => 'colors', 
    ))); 
} 
add_action('customize_register', 'mytheme_customize_register'); 

function mytheme_customize_css() 
{ 
    ?> 
    <style type="text/css"> 
     h2 { color: #<?php echo get_theme_mod('header_textcolor', "#000000"); ?>; } 
    </style> 
    <?php 
} 
add_action('wp_head', 'mytheme_customize_css'); 

出力

<style type="text/css"> 
    h1 {color:#000000;} 
</style> 
+0

返信ありがとうございました.. function.phpファイルにPHPコードを貼り付け、style.cssファイルにCSSを貼り付けました.....ページに何も表示されません –

+0

@ShanBiswas、更新された回答をご覧ください。あなたはそれを働かせましたか? – Refilon

+0

こんにちは...私はすでにあなたが上に更新したコードを入れました、それは今働いています。 –

関連する問題