Hello, friends!
I use your great plugins plugins.
Blog Categories For Groups – https://buddydev.com/plugins/blog-categories-for-groups/
BuddyPress Simple Front End Post – https://buddydev.com/plugins/bp-simple-front-end-post/Is it possible to add a link to the group in the text of the post,
under the caption of the post or at the end of the post.Thanks for helping!
Hi Vald,
Thank you for using the plugins.We do keep the group ids with the post which can be accessed using the following code
$group_id = get_post_meta( $post_id, '_bcg_group_id', true );
I am requesting Ravi to assist you with further code.
Regards
BrajeshHi Brajesh,
thanks for the tip, searched on the internet,
was able to output as an object, did it‘
$post_id = get_the_ID();$group_id = get_post_meta( $post_id, ‘_bcg_group_id’, true );
$group_obj = groups_get_group ( $group_id );
$href = bp_get_group_permalink( $group_obj );
?>
Author: *a href=”<?php echo $href;?>”><?php echo bp_group_name( $group_obj );?></a*
‘
this works for me,
maybe there is another way,
thanks for helping.- This reply was modified 2 years, 9 months ago by Vlad.
Hello Vlad,
Try the following code:
add_filter( 'the_content', function ( $content ) { if ( ! function_exists( 'groups_get_group' ) ) { return $content; } global $post; $group_id = get_post_meta( $post->ID, '_bcg_group_id', true ); $group = empty( $group_id ) ? '' : groups_get_group( $group_id ); if ( $group ) { $content = $content . sprintf( 'Associated Group: <a href="%s">%s</a>', bp_get_group_permalink( $group ), bp_get_group_name( $group ) ); } return $content; } );
it will append the associated group link with the post content.
Please let me know if it helps or not.
Regards
Ravi- This reply was modified 2 years, 9 months ago by Ravi.
The topic ‘ [Resolved] Link to the group in the text of the post’ is closed to new replies.