Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: [Resolved] Using bp displayed user to query posts

@henrywright

Moderator

Hi @robparker,

May I ask why you’re querying by username and not by user ID?

You can simply use the author parameter with WP_Query. Using what you linked to as an example:

$args = array(
    'posts_per_page' => 10,
    'paged' => $paged,
    'ignore_sticky_posts' => 1,
    'author' => $user_id
);
$query = new WP_Query( $args );

Where $user_id will be bp_displayed_user_id() if you’re doing this query on a member’s profile page. Else, it’ll be something else depending on the context in which you’re using WP_Query.

Skip to toolbar