• I am trying to display a “Visit My Blog” link on my BP profile page and the code below works when a user is logged in, but when a user is not logged in the “Visit My Blog” takes them to the main blog (domain.com), not the users blog (domain.com/user).

    <a href="<?php echo home_url() . '/' . get_the_author_meta( 'user_login', wp_get_current_user()->ID ); ?>" >Visit My Blog</a>

    If I take out the ‘user_login’ part it takes them straight to the main blog also. Any ideas on how to get the correct link to display to visitors?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter myladeybugg

    (@myladeybugg)

    Actually this code just displays the URL for whoever is logged in.

    So on user1’s blog it shows user1’s blog, but if I navigate to user2’s blog, the URL is still to user1’s blog, not user2’s.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    home_url() is relative to where you are. You’d have to do a different check to see what blog is ‘theirs’ and parse that. I’m blanking on what it is, but someone else did that…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display URL of a child site blog to visitors’ is closed to new replies.