Home Forums Add-ons Repeater Field Page Link field in a repeater?


Page Link field in a repeater?

  • I have created a repeater field where the repeated element is a page link field.

    I’m not sure of the syntax for getting the link name and url of each link. I know how to loop through a repeater, but not the syntax for the page link. For example:

    <?php if( get_field('related_assets') ): ?>
    		<?php while( has_sub_field('related_assets') ): the_row();
    		$related = get_sub_field('related_asset');
    		<li><?= $related; ?></li>
    		<?php endwhile; ?>
    <?php endif; ?>

    Which gets me:


    The links are correct, but how to get the label (what was displayed in the link menu in the editor mode)?

  • Hi @smlombardi

    The page link field will only return the url to the post, not it’s title.

    It is possible to get the raw page link value which is a post ID.
    You can do this by adding an extra ‘false’ param to your get_sub_field function.

    With the ID, you can load both the URL and the title via PW functions such as:


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

The topic ‘Page Link field in a repeater?’ is closed to new replies.