Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.0k views
in Technique[技术] by (71.8m points)

php - How to create a Call to Action button on a banner using Wordpress Customizer

I'm a WordPress beginner. This is my first question in Stackoverflow.

I am using the theme (wp bootstrap starter) I want to add an action call button, I have managed to show the button and customize it from the wordpress customizer but I have not been able to with the URL for the button. I also want that when there is no text in the button, it does not show it to me in the front-end

Can someone help me with this please, I really appreciate it.

This is the code i am using:

functions.php

$wp_customize->add_setting( 'header_banner_button_setting', array(
        'default' => __( 'Button' ),
        'sanitize_callback' => 'wp_filter_nohtml_kses',
    ) );
    $wp_customize->add_control( new WP_Customize_Control($wp_customize, 'header_banner_button_setting', array(
        'label' => __( 'Banner Button', 'wp-bootstrap-starter' ),
        'section'    => 'header_image',
        'settings'   => 'header_banner_button_setting',
        'type' => 'text'
    ) ) );

header.php

<button>
    <?php
          if(get_theme_mod( 'header_banner_button_setting' )){
             echo esc_attr( get_theme_mod( 'header_banner_button_setting' ) );
          }else{
             echo esc_html__('','wp-bootstrap-starter');
               }
    ?>
</button>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...