[英]How to put PHP code in wordpress pagination function (previous_post_link,next_post_link,etc)?
I want to put PHP code in my pagination: 我想将PHP代码放入分页中:
<?php next_post_link('%link','<div class="nav-next" title="<?php the_title();?>">Next Post</div>')?>
However, the result is I got a text: "" instead of the real title post when I hover my pagination link. 但是,结果是,当我悬停我的分页链接时,我得到一个文本:“”,而不是真实的标题。
How to get my php code works inside that wordpress parameter? 如何让我的PHP代码在该wordpress参数内工作?
Thanks. 谢谢。
There is no need for get_the_title. 不需要get_the_title。 next_post_link already makes the title of the next post available, via %title
next_post_link已通过%title使下一篇文章的标题可用
next_post_link( '%link', '<div class="nav-next" title="%title">Next Post</div>' )
Use string concatenation and get_the_title()
which returns the value rather than echoing it: 使用字符串串联和
get_the_title()
返回值而不是回显它:
<?php
next_post_link(
'%link',
'<div class="nav-next" title="'.get_the_title().'">Next Post</div>'
)?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.