plugins - Custom author page for custom role

admin2025-06-04  2

I have created my own author page (author.php) where all the posts from that author is listed. The link to that page is - localhost/abc/author/new-user/. This is working fine in localhost. But the same code is not working in my live site. The url in the live site is same as localhost- example/author/new-user/. When visited this url, it redirects to archive.php and nothing found message is displayed even though posts are there for the user.

I have a function to handle this. Below is the code how I am handling this.

    add_filter( 'template_include', array( $this, 'abc' ),100 );
        function abc( $template_path ) {
            global $post;
            $user_meta = get_userdata($post->post_author);
            $user_roles = $user_meta->roles;
            if( $user_roles[0] == 'trip_vendor' && is_author() )
            {
                if ( $theme_file = locate_template( array ( 'author.php' ) ) ) {
                    $template_path = $theme_file;
                } else {
                    $template_path = VENDOR_BASE_PATH . '/public/vendor-templates/profile/author.php';
                }
            }
}

Hopefully someone can shade some light on this.

Thank you.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748979679a315343.html

最新回复(0)