我有一个自定义的元信息显示(作者姓名、日期和类别)。因此,我想按作者显示所有帖子的自定义链接。默认情况下,我有这个<?php the_author_posts_link(); ?>
它显示作者的名字,如果你按下它,你就会得到我想要的。在索引上。php实际上是我想要的,但在单条上。php我希望有类似“按作者查看所有页面”的文本,如果您按下它,它应该与添加<?php the_author_posts_link(); ?>.
我应该从哪里开始处理这个问题?谢谢
我想添加一个自定义的“所有作者的帖子”作者的名字。多么?
1 个回复
SO网友:kaiser
附加一个过滤器,当你在单条线上时,它只输出不同的链接。php:
function wpse25725_author_posts( $link )
{
// abort if not on single.php
if ( ! is_single() )
return;
// modify this as you like - so far exactly the same as in the original core function
// if you simply want to add something to the existing link, use ".=" instead of "=" for $link
$link = sprintf(
\'<a href="%1$s" title="%2$s" rel="author">%3$s</a>\',
get_author_posts_url( $authordata->ID, $authordata->user_nicename ),
esc_attr( sprintf( __( \'Posts by %s\' ), get_the_author() ) ),
get_the_author()
);
return $link;
}
add_filter( \'the_author_posts_link\', \'wpse25725_author_posts\' );
结束