I want to display a list of related post titles as links at the bottom of a post.
I am storing a comma delimited list of post id's under a custom field called related - example: 78,167
At the bottom of single.php, under the main content output, I would like the list of related post titles.
Here are the 2 things I have tried:
<!-- Option 1 -->
<? if (get_post_meta($post->ID, 'related', true)) { ?>
<? $posts=get_post_meta($post->ID, 'related', true); ?>
<ul><?php wp_list_pages('include='.$posts.'&title_li='); ?></ul>
<? } ?>
<!-- Option 2 -->
<? if (get_post_meta($post->ID, 'related', true)) { ?>
<ul>
<? $myposts=get_post_meta($post->ID, 'related', true); ?>
<? foreach( $myposts as $post ) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
<? } ?>
Can someone point me in the right direction?