LinkThroughs II

A couple of minor changes to the ‘Related Links’ portions that appear in the individual posts. There’s no need to show the ‘Related Links’ portion when there are no external links. This is what the code looks like right now (in the file single.php):


<div id="sidebar">
<?php $stage = get_post_meta($id, '*YOURCUSTOMFIELDNAME*', TRUE);
if (!empty($stage)) { ?>
<ul><li>
<h2>LinkThroughs</h2>
<ul>
<?php $arrays = explode("\n", $stage);
foreach ($arrays as $value) {
echo '<li class="postmetadata alt">' . $value . '</li>'; } ?>
</ul>
</li>
</ul>
<p class="postmetadata alt">The
author of this site is not responsible for
the content of external internet sites </p>
<?php } ?>
</div>

Make sure to name your custom field name and to change it in the code above. Also note that I use the newline character as the divider and that the $id is a global variable too! That text area box in the post.php is a bit small. Another part: I added a new ‘div’ box (class of sidebar) to the single.php file, because my template can handle that extra box. If you do not use a Kubrick-like theme, play around with floating boxes (careful: IE may not really like it, while Firefox and Opera will take those).

Next up, actually integrate this into a plugin or in the post.php page itself.

This entry was posted in Truro NS. Bookmark the permalink.