WordPress customizer - replace text in get_theme_mod
我在Wordpress主题和页脚段落中有页脚。
看起来像这样:
1 2 3 | <p> <?php echo get_theme_mod( 'site_intro' ); ?> </p> |
当您在定制程序中时,可以选择在页脚中更改文本。
我想默认显示,例如:
版权所有2014。
这是默认文本,如果用户更改此文本,则该文本将替换为Copyright 2014,并且它将是用户已设置的文本。
在footer.php,functions.php中需要编写一些代码的地方,定制程序的其余代码在哪里?
这是使用if else语句完成的,还是Wordpress中有一些预制的代码?
这是functions.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 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' ); |
您可以使用
1 2 |
我没有看到任何代码,所以我无法告诉您如何更新功能以获取所需的内容。 但是,我将根据到目前为止所看到的给出解决方案。
您可以在页脚中执行此操作。
1 2 3 4 5 6 7 8 9 10 |