BuddyDev

Search

Trying to improve the Group home page

  • Keymaster
    (BuddyDev Team)
    Posts: 24599
    Brajesh Singh on #1726

    Hi George,
    You can access the page id as following

    
    
    $page_id = groups_get_groupmeta( bp_get_current_group_id(), 'bpge' );
    
    

    Then simply a get_post() on that and echoing the $post->post_content will be enough.

    Hope that helps.

  • Participant
    Level: Master
    Posts: 413
    Venutius on #1732

    Sorry Brajesh that not simple enough for me, how would I use get_Post()? I’m really not that great with php.

  • Keymaster
    (BuddyDev Team)
    Posts: 24599
    Brajesh Singh on #1733

    Hi George,
    here is the snippet you can use in your front page

    
    $page_id = groups_get_groupmeta( bp_get_current_group_id(), 'bpge' );
    
    if( $page_id ) {
    	
    	$post = get_post( $page_id );
    	
    	//echo get_the_title( $post ); //uncomment for title
    	
    	echo apply_filters( "the_content", $post->post_content );
    }
    
    

    Hope that helps.

  • Participant
    Level: Master
    Posts: 413
    Venutius on #1737

    I can’t get this to work, could you explain what it is doing? I think it is looking for a page called “bpge” under the current group id and then displaying its content but I’m not sure.

    I set changed the name of the Extras page to be the same but it showed no output, not event an error code.

  • Keymaster
    (BuddyDev Team)
    Posts: 24599
    Brajesh Singh on #1738

    Hi George,

    1. It looks for the the current page( custom post type) associated with group. If it finds an ID, then it tries to display the content.

    ‘bpge’ is a meta key and has nothing to do with the page slug. BP Extras uses it to store the associated page id. Please try debugging it by doing some print_r on the ID/post etc.

You must be logged in to reply to this topic.

This topic is: not resolved