简体   繁体   English

Buddypress的主要作者网址

[英]Buddypress overriding author url

I am getting author's url on Wordpress from outside the loop using this: 我正在使用以下方法从循环外部获取Wordpress上的作者网址:

<?php
get_author_posts_url( $author_id, $author_nicename );
?> 

Which works fine by delivering the author URL in this format - 通过以这种格式提供作者网址,效果很好-

mysitename.com/author/john-james . mysitename.com/author/john-james

However when Buddypress is enabled, this same URL changes to 但是,启用Buddypress时,此URL更改为

mysitename.com/members/john-james mysitename.com/members/john-james

Is there a way to prevent this from happening? 有办法防止这种情况发生吗?

get_author_posts_url() calls $wp_rewrite->get_author_permastruct() which by default returns: get_author_posts_url()调用$wp_rewrite->get_author_permastruct() ,默认情况下返回:

$this->author_structure = $this->front . $this->author_base . '/%author%';

The WP_Rewrite class has this filter which may let you change the values: WP_Rewrite类具有此过滤器,可以让您更改值:

apply_filters( 'author_rewrite_rules', array $author_rewrite )

All this is info is from the WP Codex. 所有这些信息都来自WP Codex。

I eventually have to use this code - <?php echo get_site_url(); ?>/author/<?php echo($user_name); ?> 我最终必须使用此代码- <?php echo get_site_url(); ?>/author/<?php echo($user_name); ?> <?php echo get_site_url(); ?>/author/<?php echo($user_name); ?> <?php echo get_site_url(); ?>/author/<?php echo($user_name); ?> where $user_name = $user_info->user_nicename; <?php echo get_site_url(); ?>/author/<?php echo($user_name); ?>其中$user_name = $user_info->user_nicename;

This also gets me - mysitename.com/author/john-james 这也让我-mysitename.com/author/john-james

There may be other ways, but this allows me to use the two URLs together for different purposes, one to check the author's profile (through buddypress) and the other to view all author's articles. 可能还有其他方法,但这使我可以将两个URL一起用于不同的目的,一种用于检查作者的个人资料(通过buddypress),另一种用于查看所有作者的文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM