Support

Account

Home Forums General Issues How to display a list of links including post names Reply To: How to display a list of links including post names

  • Hi @jossoway

    I think you’d be much better of using the relationship field! That way your client can search and filter to find the appropriate posts they want to link to.

    Then in your code, to display a simple list of links with the post name you can do something like this:

    
    <?php $articles = get_field('list_of_links'); ?>
    <?php if( $articles ): ?>
    	<ul>
    		<?php foreach( $articles as $article ): ?>
    			<li>
    				<a href="<?php echo get_permalink($article->ID); ?>" title="<?php echo __('Read more about') . ' ' . $article->post_title; ?>">
    					<?php echo $article->post_title; ?>
    				</a>
    			</li>
    		<?php endforeach; ?>
    	</ul>
    <?php endif; ?>