Prior to installing WordPress on my website, I created several ‘posts’ that I would like my “previous post” link to, following these rules:
- Look for WordPress created posts
- If no WordPress-created post exists, link to a specific URL
How can that be accomplished?
The several things I have tried have not worked and i am having a difficult time finding info online. Here is my code:
<?php define('WP_USE_THEMES', false); get_header(); ?>
<link href="style.css" rel="stylesheet" type="text/css" />
<table id="Table_03" width="855" border="0" cellpadding="0" cellspacing="0">
<tr style="height:251px">
<td width="162" valign="top" align="right"><br><br><p>
<a href="../../../../about.php"><span class="text6">about us </span><span class="text4">/</span><br>
</a><p>
<a href="../../../../culture.php"><span class="text6">our culture </span><span class="text4">/</span><br>
</a><p>
<a href="../../../../partners.php"><span class="text6">partner profiles </span><span class="text4">/</span><br>
</a><p>
<a href="../../../../CEDA.php"><span class="text6">CEDA </span><span class="text4">/</span><br>
</a><p>
<a href="../../../../news.php"><span class="text4">news </span><span class="text4">/</span><br>
</a><p>
</td>
<td width="59" valign="bottom" align="left"></td>
<td width="532" height="330" valign="top" align="justify"><br><br><p>
<span class="text4">news /</span><br>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<!--?php the_ID(); ?-->">
<div class="entry; text5"><?php single_post_title(); ?></div><p>
<div class="entry; text5"><?php the_content(); ?></div>
</div>
<?php endwhile; ?>
<td width="102" valign="bottom" align="left"></td>
</tr>
</table>
<table id="Table_07" width="855" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="221" height="20"></td>
<td width="532">
<span class="class6" style="float : left; text-align : left;" align="left">
<?php previous_post_link('%link', 'previous /', TRUE ); ?></span>
<span class="class6" style="float : right; text-align : right;" align="right">
<?php next_post_link('%link', '/ next', TRUE); ?></span>
<?php endif; ?>
</td>
<td width="102"></td>
</tr>
</table>
<?php get_footer(); ?>
get_previous_posts_link()
returns the previous post link as a string (empty if there aren’t any previous posts):