Skip to:
Content
Pages
Categories
Search
Top
Bottom

Recent Member Posts on Member Profile

  • Avatar of hughshields
    hughshields
    Participant

    @hughshields

    I am trying to add a list of member posts in the sidebar of the buddypress member profile page. I am using a widget with widget logic bp_is_member() to show only on member pages and using the short code [latestbyauthor author="displayed_user" show="3"] which shows all member posts. Can someone help me to tweek this short code to show just the posts of the member on the buddypress profile page or give me an idea how to solve this problem.
    Thank you!
    Hugo

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of azchipka
    azchipka
    Participant

    @azchipka

    @hughshields this should resolve your issue, just insert it into your bp-custom.php file.

    //POSTS ON PROFILE STARTS HERE
    add_action( 'bp_setup_nav', 'add_profileposts_tab', 100 );
    function add_profileposts_tab() {
    global $bp;
    bp_core_new_nav_item( array(
    'name' => 'My Posts',
    'slug' => 'posts',
    'screen_function' => 'bp_postsonprofile',
    'default_subnav_slug' => 'My Posts', 
    'position' => 25
    )
    );
    // show feedback when 'Posts' tab is clicked
    function bp_postsonprofile() {
    add_action( 'bp_template_content', 'profile_screen_posts_show' );
    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }
    
    function profile_screen_posts_show() {
    $theuser = bp_displayed_user_id(); 
    query_posts("author=$theuser" );
    get_template_part( 'loop', 'archive' ); //call your archive template
    
    }
    
    }
    
    //POSTS ON PROFILE ENDS HERE
    Avatar of azchipka
    azchipka
    Participant

    @azchipka

    Sorry there was an error in the above code, that results in a no results dialog error for users who have no posts. You can download a bundled plugin by clicking here.

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

You must be logged in to reply to this topic.