高级自定义字段链接按钮


Advanced Custom Fields Link Button

在此网站上:http://www.berkeleysg.com/"获取报价"按钮在header.php中进行了硬编码,如下所示:

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

我想用高级自定义字段替换该代码,但我是ACF的新手。

我已经创建了一个字段组,其中有两个文本字段-一个用于标签,一个用于链接,但我真的很不知道如何实现它,我找不到关于这个基本任务的信息。

我终于想通了。我是ACF的新手,它看起来比实际更难。我不得不在主页组中添加两个子字段,然后将模板代码从更改为

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

至:

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