Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Custom Posts on Profile


Shrikant Joshi
Member

@shrikantjoshi

Ah, 8 months and no reply. I figured, it’d be a long time before anyone answered to this thread, so I got down to get my hands dirty.

Now, I’m not a developer at all, so most of my hacks are just that – hacks. Well, anything will do as long as it gets the code working, I figured. If anyone wants to modify the hack into something more elegant, be my guest!! :)

Two changes:

1. Change line 45 in `wp-content/plugins/bp-posts-on-profile/includes/bp-postsonprofile-core.php` from:
`$where = $wpdb->prepare(‘WHERE post_author = %d AND post_type=%s AND post_status=%s’, $user_id, ‘post’, ‘publish’);`
to:
`$where = $wpdb->prepare(‘WHERE post_author = %d AND (post_type = %s OR post_type=%s) AND post_status=%s’, $user_id, ‘post’, ‘your-custom-post’, ‘publish’);`

where `your-custom-post` is the name of your custom post type. If you have more than one custom post, you’ll have to make changes to the part where it says: ‘(post_type = %s OR post_type=%s)’ to include all of them. (Like I said, inelegant, but mostly effective)

2. Change line no.25 in `/wp-content/plugins/bp-posts-on-profile/includes/templates/postsonprofile/screen-one.php` from:
`query_posts(‘&author=’. bp_displayed_user_id() .’&paged=’. bp_pop_cur_page());`
to:
`query_posts(‘post_type=any’ .’&author=’. bp_displayed_user_id() .’&paged=’. bp_pop_cur_page()); `

If you’re wondering, “Can it really be so simple?” The answer is, NO. There’s a tiny little problem – for some reason, it breaks the sidebar and pushes it below the content. I’m still racking my brains to figure out which part of the code is responsible.

As I’ve mentioned I’m NOT a developer – I’ve taken to learning PHP & WordPress from the ground up. If anyone else can chip in it’d be a great help! Thanks & hope it helps you as well. :)

Skip to toolbar