[Resolved] Show posts written by user on profile
-
Is it possible to add a new link to the profile which displays the posts written by the user?
By plugin would be ideal, but I can also modify the theme.
-
I’m not using groups, or multi sites. This is a central community blog that members can contribute to.
Anything’s possible, but I think you’d have to write it yourself. Unless there is a plugin that loads RSS feeds in a new tab in the member profile (I haven’t seen one before).
Two solutions — simple link in profile header vs. profile tab
For the first: just add a link to the author archive (standard WordPress) for the displayed user in the member-header file.
For the second – Have a look at bp-skeleton component.
Create a really stripped down version which just contains the code to set up your screen (profile tab), and in there do a simple wp_query() loop with the author ID set to the displayed user ID.
There is (was) a plugin bp-posts-on-profile at http://wordpress.org/extend/plugins/bp-posts-on-profile/ though it is very out of date and hasn’t been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress and BuddyPress.
I have tried it out with bp 1.6 and wp 3.4.1 and with a host of other bp plugins in a multisite and also in a multi-network local test site.
As far as Multi-Site/Multi-Network it was unsatisfactory as it only drew in blog posts from the main blog.
It did not draw in posts from (say) a group blog.
However for anyone who authored a post on the Main Blog it dragged in that post and showed it on their profile under the tab Posts
Those more qualified might look at the code and see if it would take much to have it brought fully up to date and multi-site compatible.
However as all relevant details including of posts are included in the members activity tab it probably is not as vital as other plugin development ?
On that note is there any kind of group funding facility for plugin development. So that those who want but can’t could collectively fund those who can ? or would something like that ever work ?
Thanks Valuser, that’s very helpful. My project only has a central blog that the community contributes to anyway, so this sounds promising. I’ll give it a go and let you know how it goes. It might requires a bit of hacking if it’s so old.
Anyone interested in some paid development to update the plugin if it isn’t working?
Just tried it out and it works perfectly

Buddypress 1.6 and WordPress 3.4.1.
However it doesn’t use the excerpt, it uses the first X of the post. It actually pulls quite a lot which is not so good for SEO since it will produce a lot of duplicate content.
I’ll see if I can find where it defines how much to pull in from the post.
I tried pasting the code in backticks, but the post doesn’t seem to show up.
Just wondering if there is a way to modify the plugin code to use the excerpt rather than first few paragraphs.
@djduckworth I haven’t used the plugin before. Looking at plugin files, looks like you simply just need to open up bp-posts-on-profile/includes/templates/postsonprofile/screen-one.php file with a text editor and change the_content to the_excerpt
Worked perfectly! Thanks @mercime.
OK went through the plugin and updated the code to function in current versions of buddy press, its a bit sloppy but it does work. Just place the below code in your bp-custom.php file and it will add a new tab to each users profile that displays the blog posts they have written. Display is based off of your archive.php file so it matches the theme.
//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 HERESorry 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.
if ( !function_exists( 'add_action' ) ) { echo 'Hi there! I\'m just a plugin, not much I can do when called directly.'; exit; } define('TCH_PostsOnProfilesVersion', '0.1'); define('TCH_PostsOnProfilesVersion_PLUGIN_URL', plugin_dir_url( __FILE__ )); 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" ); if ( have_posts() ) : get_template_part( 'loop', 'archive' ); else: ?>Use the download link the forum keeps stripping out a portion of the code.
You must be logged in to reply to this topic.