Support

Account

Home Forums Front-end Issues Having difficult pulling button from page

Unread

Having difficult pulling button from page

  • I’m trying to pull an image from a page and have it loop through another page.

    I have a file called page-builder-img_buttons.php and the code is:

    while ( have_rows( 'image_buttons' ) ) : the_row();
      $bg_img = get_sub_field( 'image' );
      $bg_img = wp_get_attachment_image_src( $bg_img, 'img-btn-gray' );
      $bg_img = $bg_img[0];
    
      ?>
        <a href="<?php the_sub_field( 'link' ); ?>" class="" style="background-image: url( <?php echo $bg_img; ?> );">
            <span class="overlay">
              <?php the_sub_field( 'button_text') ?>
            </span>
        </a>
      <?php endwhile; ?>

    and then I’m trying to grab it from content-page.php and here is the code:

    // check if the flexible content field has rows of data
    if( have_rows('image_buttons')):
        // loop through the rows of data
        while ( have_rows('image_buttons') ) : the_row();
           get_template_part('template/page-builder-', get_row_layout());
        endwhile;
    endif;
    ?>

    Any help is appreciate it.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.