Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Create shortcode for link to post author

  • @redlosh

    Participant

    Hi,
    I am try to make shortcode to get link to author profile of current post:

    function authorlink_my() {
    $link = bp_core_get_userlink( $post->post_author ) ;
    return $link;
    }
    add_shortcode( 'authorlink', 'authorlink_my' );

    but without any success for now.

    Any help?

Viewing 4 replies - 1 through 4 (of 4 total)
  • @danbp

    Participant

    Try

    function authorlink_my() {
    $name = get_the_author();
    $url = bp_core_get_user_domain( get_the_author_meta( 'ID' ) );
    	
    	return '<a href="'. $url .'" title="Go to author\'s profile">'. $name .'\'s Profile</a>';
    }
    add_shortcode( 'authorlink', 'authorlink_my' );

    @redlosh

    Participant

    Great! It works.
    I was trying for whole day to do it….

    Many Thanks @danbp

    @danbp

    Participant

    You’re welcome. 😉
    In case of, here’s another trick.

    @redlosh

    Participant

    That one was what I used as my template 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Create shortcode for link to post author’ is closed to new replies.
Skip to toolbar