Hello,
Please how can I add a new Read More link after the new_blog_post activity type while using the buddyblog pro plugin.
I have tried this code but did not work
function bp_activity_read_more() { if ( bp_is_active('activity') ) { global $activities_template; if ( 'new_blog_post' === $activities_template->activity->type ) { $activity = $activities_template->activity; $post_id = $activity->primary_link; $excerpt = bp_create_excerpt( $activity->content ); $url_ad = get_permalink( $post_id ); echo '<div class="activity-content">'; echo '<p class="activity-excerpt">' . esc_html( $excerpt ) . '</p>'; echo '<div class="read-more"><a href="' . esc_url( $url_ad ) . '">Read More</a></div>'; echo '</div>'; } } } add_action( 'bp_before_activity_loop', 'bp_activity_read_more' );
Thanks Ravi,
This code below worked for me
function bp_activity_read_more( $content, $activity ) { if ( 'new_blog_post' === $activity->type ) { $post_id = $activity->secondary_item_id; $post_url = get_permalink( $post_id ); // Append the "Read More" link to the content $read_more_link = '<div class="read-more"><a href="' . esc_url( $post_url ) . '">Read More</a></div>'; $content .= $read_more_link; } return $content; } add_filter( 'bp_get_activity_content_body', 'bp_activity_read_more', 10, 2 );
Viewing 4 posts - 1 through 4 (of 4 total)
The topic ‘ [Resolved] Add Read More link to buddypress activity excerpt’ is closed to new replies.
This topic is: resolved