【问题标题】:Post navigation code发布导航代码
【发布时间】:2011-12-16 17:59:50
【问题描述】:

我在首页中使用此代码进行导航:

<h13><div class="navigation">

<div class="next-posts">
    <div id="image_left"><?php next_posts_link('<img src="IMG URL"/>') ?></div>

    <div id="posts_left"><h12><?php next_posts_link('Older Stuff') ?></h12></div>
</div>

<div class="prev-posts">
    <div id="posts_right"><h12><?php previous_posts_link('Newer Stuff') ?></h12></div>

    <div id="image_right"><?php previous_posts_link('<img src="IMG URL"/>') ?></div>
</div>

我希望我的单个帖子视图使用相同的导航,但我无法让它工作,我对 PHP 函数进行了更改,但在 Codex 中我只发现了一个显示同一类别的帖子的方法。 另外,我不希望链接显示上一篇/下一篇文章的标题,只显示我定义的文本。 最后一件事,我根本无法让图像导航在单一视图中工作,但它在我的主页中确实可以完美地工作。

这是我目前的代码:

<h13><div class="navigation">

<div class="next-post">
    <div id="img_left"><?php next_post_link('<img src="IMG URL"/>') ?></div>

    <div id="post_left"><h12><?php next_post_link('%link', 'Next post', TRUE); ?></h12></div>
</div>

<div class="prev-post">
    <div id="post_right"><h12><?php previous_post_link('%link', 'Previous post', TRUE); ?></h12></div>

    <div id="img_right"><?php previous_post_link('<img src="IMG URL"/>') ?></div>
</div>

【问题讨论】:

    标签: wordpress navigation


    【解决方案1】:

    h13 和 h12?我不知道标题会这么高!

    我猜你已经阅读了Codex Page for the next_post_link() function. 但是你确定将调用包含在循环中吗?另外,尝试在函数中添加额外的参数。有时他们会感到困惑。

    【讨论】:

    • 我使用了h12/h13,以便更轻松地控制它们。我阅读了有关该主题的 Codex,但如果不显示帖子标题,我就无法让它工作。仅使用上面的代码它不会显示标题。
    • 显示图像的问题是我确实必须添加额外的参数,所以图像代码是:&lt;?php previous_post_link('%link', '&lt;img src="IMG URL"/&gt;', FALSE) ?&gt;,而从同一类别显示的问题是我没有阅读 CODEX true/false 参数的问题。将其更改为 FALSE 使代码完美。
    猜你喜欢
    • 2015-10-28
    • 2021-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多