Support

Account

Home Forums General Issues Page Link in Repeater Field

Solving

Page Link in Repeater Field

  • Anyone else have this same issue? I’ve got a page link sub field within a repeater field and it happens to call the page name not the permalink when called. I’ve followed the syntax within the documentation. Here is an example of my code below:

    <?php if(have_rows('section')): ?>
        <?php while (have_rows('section')) : the_row(); ?>
            <a class="btn" href="<?php the_sub_field('button'); ?>" role="button">Button Text</a>
        <?php endwhile; ?>
    <?php endif; ?>

    I’ve put in a fix myself by using a combination of get_page_by_path() and the_permalink() functions, but was wondering if I was doing anything wrong or this might be an issue with ACF.

    <?php if(have_rows('section')): ?>
        <?php while (have_rows('section')) : the_row(); ?>
            <a class="btn" href="<?php the_permalink(get_page_by_path(get_sub_field('button'))); ?>" role="button">Button Text</a>
        <?php endwhile; ?>
    <?php endif; ?>

    Thanks.

  • Hi @santowhir

    I’ve just tried it on my installation but failed to reproduce the issue. Could you please try to reproduce the issue on one of the WordPress’ stock themes (like Twenty Sixteen) with other plugins deactivated? If it disappears, then you can activate the theme and plugins one by one to see which one causes the issue.

    Thanks 🙂

  • Hi James,

    Thanks for the response.

    I just tried it without any other plugins and on the Twenty Fifteen theme and it worked as expected.

    I’ll go through the plugins and theme to see if this is the issue.

    Thanks.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Page Link in Repeater Field’ is closed to new replies.