Skip to content

Instantly share code, notes, and snippets.

@miya0001 miya0001/1.php
Created May 20, 2012

Embed
What would you like to do?
テーマカスタマイザー
<?php
add_action( 'customize_register', 'themename_customize_register' );
function themename_customize_register($wp_customize) {
// ここでいろいろと
}
<?php
add_action( 'customize_register', 'themename_customize_register' );
function themename_customize_register($wp_customize) {
// セクションを追加
$wp_customize->add_section( 'twentyeleven_logo_image', array(
'title' => 'ロゴ画像',
'priority' => 15,
) );
}
<?php
add_action( 'customize_register', 'themename_customize_register' );
function themename_customize_register($wp_customize) {
// セクションを追加
$wp_customize->add_section( 'twentyeleven_logo_image', array(
'title' => 'ロゴ画像',
'priority' => 15,
) );
// セクションの動作設定
$wp_customize->add_setting( 'twentyeleven_logo_image', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
) );
}
<?php
add_action( 'customize_register', 'themename_customize_register' );
function themename_customize_register($wp_customize) {
// セクションを追加
$wp_customize->add_section( 'twentyeleven_logo_image', array(
'title' => 'ロゴ画像',
'priority' => 15,
) );
// セクションの動作設定
$wp_customize->add_setting( 'twentyeleven_logo_image', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
) );
// セクションのUIを作成する
$wp_customize->add_control( new WP_Customize_Image_Control(
$wp_customize,
'logo_Image',
array(
'label' => '画像',
'section' => 'twentyeleven_logo_image',
'settings' => 'twentyeleven_logo_image',
)
) );
}
<hgroup>
<?php if (get_option('twentyeleven_logo_image')): ?>
<h1 id="site-title""><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><img alt="<?php bloginfo( 'name' ); ?>" src="<?php echo esc_url(get_option('twentyeleven_logo_image')); ?>" /></a></h1>
<?php else: ?>
<h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1>
<?php endif; ?>
<h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
</hgroup>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.