Home Forums General Issues link array: url works but page title doesn't show


link array: url works but page title doesn't show

  • I’m using a link array. The code below gets the correct url, but neither the target nor the title are showing up.

    <?php $link = get_sub_field('link');
    	if( $link ): ?>
    	<p><a class="button" href="<?php echo $link['url']; ?>" target="<?php echo $link['target']; ?>"><?php echo $link['title']; ?>will be page title</a></p>
    	<?php endif; ?>

    The code is directly from this page

  • I’m using a repeater field and this worked for me:

    <?php if( have_rows('lista_de_encuestas') ) : while ( have_rows('lista_de_encuestas') ) : the_row(); ?> 
        $pollUrls = get_sub_field('enlace_a_encuesta');
          <a href="<?php echo $pollUrls['url']; ?>"><?php echo $pollUrls['title']; ?></a>
    <?php endwhile; endif; ?>

    Not sure if the if statement has something to do with it. I tried the same thing over and over and for some reason when I deleted everything and did it over again it worked. I triple checked the code before and I don’t think I had any typos or errors but… who knows :/

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

You must be logged in to reply to this topic.