如何利用wordpress中的函数获取指定作者页面的链接url,下面web建站小编给大家简单介绍一下关于get_author_posts_url()函数的基本用法!
函数原型:
get_author_posts_url( int $author_id, string $author_nicename = '' ): string
参数说明:
$user_id:用户ID
$author_nicename:用户 slug 。
函数源码:
function get_author_posts_url( $author_id, $author_nicename = '' ) {
global $wp_rewrite;
$author_id = (int) $author_id;
$link = $wp_rewrite->get_author_permastruct();
if ( empty( $link ) ) {
$file = home_url( '/' );
$link = $file . '?author=' . $author_id;
} else {
if ( '' === $author_nicename ) {
$user = get_userdata( $author_id );
if ( ! empty( $user->user_nicename ) ) {
$author_nicename = $user->user_nicename;
}
}
$link = str_replace( '%author%', $author_nicename, $link );
$link = home_url( user_trailingslashit( $link ) );
}
$link = apply_filters( 'author_link', $link, $author_id, $author_nicename );
return $link;
}
包含钩子:
apply_filters( 'author_link', string $link, int $author_id, string $author_nicename )
使用举例:
显示当前文章作者的作者页面链接。
<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" title="<?php echo esc_attr( get_the_author() ); ?>"><?php the_author(); ?></a>
wordpress建站如何快速提交和优化您的网站(IndexNow插件)?
上面是“wordpress如何获取指定作者页面的链接url”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4404.html
workflows工作流
小丑鱼马林在鱼缸里游来游去ComfyUI工作流
一碗热气腾腾的拉面ComfyUI工作流
一个由红色玻璃制成的女性形状的破碎雕塑
一个超现实和超现实的场景,在森林中心有一座蛇形的房子
懂王特朗普3d漫画ComfyUI工作流
图片转视频ComfyUI工作流
骨骼般的恶魔修女ComfyUI工作流
令人着迷的一只老虎ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

javascript如何利用draggable实现一个拖拽效果
如何利用svg做一个有趣的loading动画加载
css3搭积木叠加图形
css3动画loading效果
纯html+css做一个3d统计效果
纯css3绘制的小鸟
css3实现星球旋转
css3结合svg做一个动态广告










