Skip to:

[Resolved] Populating BP Profile Loop for author of a WP Post

  • atburi


    Hi everyone,

    I would like to use the bp_has_profile() loop to run through the profile fields of authors on my WordPress single.php page.

    I know it goes something like: <?php if ( bp_has_profile( 'user_id=10' ) ) : ?> .....

    But my issues is finding the right code to dynamically generate the user ID of the current WP post. I’ve tried using <?php if ( bp_has_profile( get_the_author_meta( 'ID' ) ) ) : ?> but that doesn’t work.

    Anyone have any ideas?

    For others interested in customizing the profile loop, check out:

Viewing 6 replies - 1 through 6 (of 6 total)

  • atburi


    This worked 🙂

    <?php if ( bp_has_profile( array( 'user_id' => $user_id ) ) ) : ?>

    Is this the best solution?

    This would work (& does work):
    bp_has_profile(‘user_id=’ . get_the_author_meta( ‘ID’ ) )

    or you could grab the user id from $post->post_author

    I’m assuming you’re running this in a single post loop.



    Thanks for the response, @hnla

    Indeed, that works; just wasn’t sure how to properly code inside a php bracket like that.

    I’m running the member’s profile loop in the sidebar of the single post page, so this would be outside the single post content loop. However, also in the side bar I use the function:

    bp_core_get_userlink( $post->post_author ) )

    and that does work, so somehow it’s getting the correct member ID outside the loop?

    If I wanted to use $post->post_author to get the ID, would it look like:

    if ( bp_has_profile( $post->post_author ) ) : ?

    $post is available as soon as you hit a post/page so doesn’t have to be in the loop

    Think my earlier example holds good for passing the id to bp_has_profile but I’d probably do $user_id = $post->post_author;



    Thanks Hugo, all makes sense….

    I’ll leave it that and mark as resolved!

    Marking as ‘resolved’ then, re-post if further issues arise.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Resolved] Populating BP Profile Loop for author of a WP Post’ is closed to new replies.
Skip to toolbar