我在Wordpress主题和页脚段落中有页脚 .
它看起来像这样:
<p><?php echo get_theme_mod( 'site_intro' ); ?></p>
当您在自定义程序中时,可以选择更改页脚中的文本 .
我希望默认显示例如:
Copyright 2014.
这是默认文本,如果用户更改此文本,则文本将为_148268_ Copyright 2014,它将是用户已设置的文本 .
在我需要制作一些代码的地方,在footer.php,functions.php中,定制器的其余代码在哪里?
这是用if else语句制作的,还是在Wordpress中有一些预制代码?
这是functions.php
function theme_customize_register( $wp_customize ) {
if ( class_exists( 'WP_Customize_Control' ) ) {
class PTD_Textarea_Control extends WP_Customize_Control {
public function render_content() {?>
<label>
<span class="customize-control-title"><?php echo esc_html( $this->label );?></span>
<textarea class="large-text" cols="20" rows="5" <?php $this->link(); ?>>
<?php echo esc_textarea( $this->value() ); ?>
</textarea>
</label>
<?php
}
}
}
$wp_customize->add_setting( 'site_intro', array(
'default' => '',
'transport' => 'postMessage'
));
$wp_customize->add_section( 'theme_site_info', array(
'title' => 'Footer informaation', 'theme',
'description' => 'Custom Footer', 'theme',
'priority' => 20,
));
$wp_customize->add_control( new PTD_Textarea_Control( $wp_customize, 'site_intro_control', array(
'label' => 'Website Footer', 'theme',
'section' => 'theme_site_info',
'settings' => 'site_intro'
)));
}
add_action( 'customize_register', 'theme_customize_register' );
2 回答
我没有看到任何代码,所以我无法告诉你如何更新函数以获得你想要的 . 但是我会根据我到目前为止所看到的情况给出解决方案 .
你可以在页脚中执行此操作 .
您可以使用
get_theme_mod
函数的第二个参数 . 您可以传递默认值作为第二个参数,如果之前未保存您的设置,将返回该参数 .