Skip to:
Content
Pages
Categories
Search
Top
Bottom

Post author Profile link


  • testamann
    Participant

    @testamann

    Im really new to php and wordpress. I wanted to figure out howto change a link which goes to an authors posts and make it bring up the authors Buddy Press Profile. I am making changes to the Author box on my website which is a part on the sidebar that displays the authors avatar. Im trying to make changes to this. to no avail. any help or other post references would be great. I havent seemed to find an answer yet. Thanks.

    <?php
        if( !isset( $post ) ){
            return '';
        }
        $meta = meta::get_meta( $post -> ID , 'settings' );
    
        if( isset( $meta[ 'author' ] ) && strlen( $meta[ 'author' ] ) && !is_author() ){
            $show_author = meta::logic( $post , 'settings' , 'author' );
        }else{
            if( is_single() ){
                $show_author = options::logic( 'blog_post' , 'post_author_box' );
            }
    
            if( is_page() ){
                $show_author = options::logic( 'blog_post' , 'page_author_box' );
            }
    
            if( !( is_single() || is_page() ) ){
                $show_author = true;
            }
        }
    
        if( ( is_single () || is_author() || is_page() ) &&  $show_author   ){
    ?>
            <aside id="archives-3" class="widget">
                <h4 class="widget-title">
                    <?php _e( 'By' , 'cosmotheme' )?>
                    <span class="vcard">
                        <a class="url fn n" href="<?php echo bp_core_get_user_domain( $user_id ) ?>" title="<?php echo esc_attr( get_the_author_meta( 'display_name' , $post-> post_author ) ); ?>" rel="me">
                            <?php echo get_the_author_meta( 'display_name' , $post-> post_author ); ?>
                        </a>
                    </span>
                    <?php
                        if( !is_author() && options::logic( 'general' , 'enb_likes' ) ){
    
                            $url = get_author_posts_url( $post-> post_author );
    
                            $all = array( 'type' => "all" );
                            $url_all = add_query_arg( $all , $url );
    
                            $like = array( 'type' => "like" );
                            $url_like = add_query_arg( $like , $url );
    
                            $like = array( 'type' => "post" );
                            $url_post = add_query_arg( $like , $url );
                    ?>
                            <span class="links">
                                <a href="<?php echo $url_all; ?>"><?php _e( 'All' , 'cosmotheme' ); ?></a>
                                <a href="<?php echo $url_post; ?>"><?php _e( 'Posts' , 'cosmotheme' ); ?></a>
                                <a href="<?php echo $url_like; ?>"><?php _e( 'Likes' , 'cosmotheme' ); ?></a>
                            </span>
                    <?php
                        }
                    ?>
                </h4>
                <div class="box-author clearfix">
                    <p>
                        <a href="<?php echo bp_core_get_user_domain( $user_id ) ?>"><?php echo cosmo_avatar( $post -> post_author , $size = '60', $default = DEFAULT_AVATAR );  ?></a>
                        <?php
                            $author_bio = get_the_author_meta( 'description' , $post -> post_author );
    
                            if( $author_bio != '' ){
                                echo '<span class="author-page">' . $author_bio . '</span>';
                            }
                        ?>
                    </p>
                </div>
            </aside>
    <?php
        }
    ?>
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • to get the authors BP account url you could try:

    bp_core_get_user_domain( get_the_author_meta( ‘ID’ )

    In the same vein you should be able to grab the BP avatar:

    bp_core_fetch_avatar( array(‘item_id’ => get_the_author_meta( ‘ID’ )


    testamann
    Participant

    @testamann

    Thanks for the response! I’ve been super swamped on this one. still am actually. I keep turning up errors for using that get user domain. Trying to figure it out today I wondered if it would be 100% easier to not change the code i have above but to just make a simple button that i can insert in my code. Is it possible to just make a text link that is relative to the author.

    some kind of View Profile

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post author Profile link’ is closed to new replies.
Skip to toolbar