0
votes

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.

1
you can create a replacement header.php in your child theme and output your new htmlDavid
What part of that code do you want to convert? It appears to already be using ACF...rnevius
I think what the client wants is to replace the link with the field "quote_link" and the button text with "quote_label" but I don't know what the correct format would be.CreativEliza

1 Answers

0
votes

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>" : "";