- This topic has 1 reply, 2 voices, and was last updated 2 years, 8 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Support › Forums › Flex Theme › How to Create Two Buttons in Flex Slider Like Home Page Banner
Tagged: Flex slider, Home Page Banner, Read More Button
Hi,
The Flex Pro demo has the Flex Slider in the Home Top section and the Home Page Banner in the Home Middle section. The Home Page Banner Widget offers the option of doing two buttons. Is there a way to create two buttons when using the Flex Slider?
Thanks,
Bill
Open the slider-cpt.php file from flex/lib/cpt folder. Enter the following PHP code above the line no 100
$btn2txt = (get_post_meta(get_the_ID(), '_btn2_txt', true)) ? get_post_meta(get_the_ID(), '_btn2_txt', true) : "";
$btn2url = (get_post_meta(get_the_ID(), '_btn2_url', true)) ? get_post_meta(get_the_ID(), '_btn2_url', true) : "";
echo '<div style="width: 90%;">';
printf( '<p><label>%s<input type="text" name="sld[_btn2_txt]" id="_btn2_txt" class="large-text" value="%s" /></label></p>', __( 'Button 2 Text: ', 'flex' ), esc_attr( $btn2txt ) );
echo '</div><br style="clear: both;" />';
echo '<div style="width: 90%;">';
printf( '<p><label>%s<input type="text" name="sld[_btn2_url]" id="_btn2_url" class="large-text" value="%s" /></label></p>', __( 'Button 2 URL: ', 'flex' ), esc_attr( $btn2url ) );
echo '</div><br style="clear: both;" />';
You will get two new custom fields in Slider CPT at your backend. You will enter the button text & URL.
Now open the flex-slider-widget.php file from flex/lib/widgets folder. Add the following code below the line no 128
$btn2Txt = get_post_meta(get_the_ID(), '_btn2_txt' ,true);
$btn2url = get_post_meta(get_the_ID(), '_btn2_url' ,true);
if( ! empty( $btn2Txt ) && ! empty( $btn2url ) )
echo '<p><a href="'.$btn2url.'" class="read-more btn-alt">'.$btn2Txt.'</a></p>' . "\n";
Note: code is not tested. You keep a backup first.