【问题标题】:Buddypress overriding author urlBuddypress 覆盖作者 url
【发布时间】:2017-11-05 05:37:03
【问题描述】:

我正在使用这个从循环外部获取作者在 Wordpress 上的网址:

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

通过以这种格式提供作者 URL 效果很好 -

mysitename.com/author/john-james

但是,当 Buddypress 启用时,这个相同的 URL 会更改为

mysitename.com/members/john-james

有没有办法防止这种情况发生?

【问题讨论】:

    标签: php wordpress buddypress


    【解决方案1】:

    get_author_posts_url() 调用 $wp_rewrite-&gt;get_author_permastruct() 默认返回:

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

    WP_Rewrite 类有这个过滤器,可以让你改变值:

    apply_filters( 'author_rewrite_rules', array $author_rewrite )
    

    All this is info is from the WP Codex.

    【讨论】:

      【解决方案2】:

      我最终不得不使用这个代码 - &lt;?php echo get_site_url(); ?&gt;/author/&lt;?php echo($user_name); ?&gt; where $user_name = $user_info-&gt;user_nicename;

      这也让我着迷 - mysitename.com/author/john-james

      可能还有其他方法,但这允许我将两个 URL 一起用于不同的目的,一个是检查作者的个人资料(通过 buddypress),另一个是查看所有作者的文章。

      【讨论】:

        猜你喜欢
        • 2011-09-04
        • 2014-02-27
        • 1970-01-01
        • 1970-01-01
        • 2012-03-15
        • 1970-01-01
        • 2015-03-13
        • 1970-01-01
        • 2017-11-04
        相关资源
        最近更新 更多