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; ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.