Skip to:
Content
Pages
Categories
Search
Top
Bottom

post type –> buddypress support


  • _natty_
    Participant

    @_natty_

    Greetings to all,

    I’m working to add some special feature to a buddypress installation, in particular I’d like to add 2 personal “post type” to the functionally of each user.
    I’ve already by pass the problem of how they can publish and adding some extra field and everything works fine.
    What I can’t understand is how to add a specific “archive post page” for each buddypress user, I just found thousand of post of how publish “post type” on activity stream but nothing about how adding buddypress user support for each post type…

    I’d like to have something like:

    http://www.mysite.com/members/userX/posttype1/
    http://www.mysite.com/members/userY/posttype1/

    http://www.mysite.com/members/userX/posttype2/
    http://www.mysite.com/members/userY/posttype2/

    Where the loop of my post type publish just post type of the selected specific user, and that these folders are aviable for all bu hoddypress user to let them to browse others post type.

    thanks

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

  • shanebp
    Moderator

    @shanebp

    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.


    _natty_
    Participant

    @_natty_

    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


    shanebp
    Moderator

    @shanebp

    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


    _natty_
    Participant

    @_natty_

    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.


    shanebp
    Moderator

    @shanebp

    'user_has_access' => true


    _natty_
    Participant

    @_natty_

    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();
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘post type –> buddypress support’ is closed to new replies.
Skip to toolbar