Since your example urls would lead to a member profile page, you want a custom page for members.
The page is available thru a tab on the member page nav.
Since you have 2 post_types, you may want sub-tabs.
Example for adding tabs and sub tabs.
That custom page should use WP_Query
to loop thru the post_type posts for that user.
if there is a better and clear stretegy for providing archive of specific type post please give me an advise…otherwise I’ll try to add this feature. thanks
providing archive of specific type post
Creating such a page is easy and well documented as a standard WP task.
The issue is that you want such a page for each user.
If you use the standard approach – how do you determine which user’s posts to display?
Creating a page or pages as I suggest above is the usual solution to that problem.
Simply use bp_displayed_user_id()
as the value for the author parameter in WP_Query
.
Or you could create profile tabs that work as links to a standard post archive page.
Those links could include the user_id as a $_GET var which you use as the value for the author parameter in the WP_Query
instance on the archive page.
But those links would be in the form of
http://www.mysite.com/posttype1/?user=2
Hi, everything now works nice, even for other user I can see the main tab, but not the subnav why?
The subnav are available just for the current user and not if I visit others people profile.
I guess that is for this:'user_has_access' => bp_is_my_profile()
But I can’t find how to correctly configurated it for having access to own sub_nav and others profile’s sub_nav.
'user_has_access' => true
so easy, so for that reason i didn’t find around LOL
many thanks.
Here for others user that needs to solve this kind of problem a piece of the code that helps me to solve the problem about showing post-type on sub-nav: This function referring to the first “animal” example goes in “function cats_screen content()
”
if ( is_user_logged_in() )
{
$autore=bp_displayed_user_id();
$args = array(
'post_type' => array('XXXX','YYYYYY'),
'orderby' => 'menu_order',
'post_status' => 'publish',
'author' => $autore,
'order' => 'ASC',
'posts_per_page'=> '12' // overrides posts per page in theme settings
);
$query=new WP_Query( $args );
if ( $query->have_posts() )
{
while ( $query->have_posts() )
{
$query->the_post();
$id = get_the_ID();
echo '<div class="post_prod">';
echo '<h3 class="title_prod"><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></h3>';
if(has_post_thumbnail())
{
echo '<div class="pic_prod">';
echo get_the_post_thumbnail($id,'thumbnail').'</div>';
}else echo '<div class="img"><img height="150" width="150" src="xxxxxxx" ></div>';
echo '<div class="exc_prod"><p>'.the_excerpt().'</p></div>';
echo '</div>';
}
}else{echo wpautop( 'Sorry, no productions found' );}
}else{echo wpautop( 'Spiacente, non sei autorizzato' );}
wp_reset_query();