1

在我的网站上安装 WordPress 之前,我创建了几个“帖子”,我希望我的“以前的帖子”链接到,遵循以下规则:

  1. 查找 Wordpress 创建的帖子
  2. 如果不存在由 Wordpress 创建的帖子,请链接到特定 URL

那怎么能做到呢?

我尝试过的几件事都没有奏效,我很难在网上找到信息。这是我的代码:

<?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(); ?>
4

1 回答 1

1

get_previous_posts_link()以字符串形式返回上一个帖子链接(如果没有任何以前的帖子,则为空):

<?php if (get_previous_posts_link()) {
  previous_post_link('%link', 'previous /', TRUE );
} else {
  echo("static text and link to other URL");
} ?>
于 2013-05-30T10:13:42.197 回答