Reputation: 271
On this site: http://www.berkeleysg.com/ the "Get a Quote" button is hard coded in the header.php as follows:
$the_text = (get_sub_field('bsg_slide_text')) ? "<span class='caption ".$options."'>".get_sub_field('bsg_slide_text')." <p style='text-align:center;'><a href='/contact/request-for-quote/' class='button'>Get a Quote</a></p></span>" : "";
I want to replace that code with an Advanced Custom Field but I am brand new to ACF.
I have created a field group with two text fields - 1 for the label and one for the link but I'm really lots as to how to implement it and I can't find info on this basic task.
Upvotes: 0
Views: 2692
Reputation: 271
I finally figured it out. I'm so new to ACF that it seemed harder than it really was. I had to add two sub fields to the homepage group and then change the template code from:
if (get_field('bsg_slider')) {
$count = 1;
echo "<div class='section' id='bsg-slider'>";
echo "<div class='cs cs-default' data-slider='isPag-on isPagNum-on' data-pagText='s.'>";
while( has_sub_field('bsg_slider') ) {
$options = "";
$img_options = "";
$the_image = get_sub_field('bsg_slide_image');
$the_image = $the_image[url];
$the_bg_image = get_sub_field('bsg_slide_bg_image');
$the_bg_image = $the_bg_image[url];
$position = get_sub_field('bsg_image_position');
$the_text = (get_sub_field('bsg_slide_text')) ? "<span class='caption ".$options."'>".get_sub_field('bsg_slide_text')." <p style='text-align:center;'><a href='/contact/request-for-quote/' class='button'>Get a Quote</a></p></span>" : "";
to:
if (get_field('bsg_slider')) {
$count = 1;
echo "<div class='section' id='bsg-slider'>";
echo "<div class='cs cs-default' data-slider='isPag-on isPagNum-on' data-pagText='s.'>";
while( has_sub_field('bsg_slider') ) {
$options = "";
$img_options = "";
$the_image = get_sub_field('bsg_slide_image');
$the_image = $the_image[url];
$the_bg_image = get_sub_field('bsg_slide_bg_image');
$the_bg_image = $the_bg_image[url];
$position = get_sub_field('bsg_image_position');
$quote_text= get_sub_field('quote_label');
$quote_url= get_sub_field('quote_link');
$the_text = (get_sub_field('bsg_slide_text')) ? "<span class='caption ".$options."'>".get_sub_field('bsg_slide_text')." <p style='text-align:center;'><a href=".get_sub_field('quote_link')." class='button'>".get_sub_field('quote_label')."</a></p></span>" : "";
Upvotes: 1