【发布时间】:2020-05-06 05:12:49
【问题描述】:
与Redirect Wordpress Media attachment page to root location、Wordpress get Post infomation from attachment和How to Redirect WordPress Attachment Page to Original Post or Page相关:
在 WordPress 附件页面上,会生成带有样式 nav_prev 和 nav_next 的链接(至少在 RDG Forest 主题中)。如何获得与他们在同一行中的中心链接,将用户链接回图片附加到的父帖子?
如果一张图片附加到多个帖子怎么办? “返回”链接如何知道去哪里?
到目前为止我的尝试:
首先为“返回父帖子”链接添加一个 CSS 样式,模仿 .nav-next 样式。
.nav-center {
float: center;
text-align: center;
width: 50%;
word-wrap: break-word;
font-size: 16px;
font-size: 1.142857143rem;
font-weight: bold;
}
.nav-next {
float: right;
text-align: right;
width: 50%;
word-wrap: break-word;
font-size: 16px;
font-size: 1.142857143rem;
font-weight: bold;
}
然后转到 image.php 并编辑上一个和下一个导航项的跨度。例如寻找:
<nav id="image-navigation" class="navigation" role="navigation">
<span class="nav-previous"><?php previous_image_link(false, __('← Previous Image', 'rcg-forest')); ?></span>
<span class="nav-next"><?php next_image_link(false, __('Next Image →', 'rcg-forest')); ?></span>
</nav>
我想使用下面的函数来获取父帖子的URL,但是我还没有弄清楚如何使用这个函数来链接跨度类文本。
get_permalink($post->post_parent)
【问题讨论】: