Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] BP WordPress Activity Stream Excerpt Problem

  • @skyseven7

    Participant

    Hello everyone, hope someone could enlighten me with this problem.
    We currently have two (2) authors in our site allowed to publish posts.Since BuddyPress is enabled (together with the Activity Stream module), all published posts and other site activity are logged.
    My question are:

    1. How come when I publish a post, the activity stream only shows the excerpt and would end in a […]?
    2. But when the other author publishes his post, it would be posted in the whole activity stream with a toggleable [Read More] button.

Viewing 5 replies - 1 through 5 (of 5 total)
  • @marcella1981

    Participant

    It’s actually the Site Tracking in conjunction with Activity Stream which allows for post publishing to be tracked.

    I don’t know exactly what you’re trying to do here, but you could first start by increasing the excerpt length to be a little longer. I’m not sure what the default excerpt length is for BuddyPress, however the function below will increase it to 750 characters.

    Place the function below into functions.php or bp-custom.php

    function px_bp_activity_excerpt_length() {
        return 750;
    }
    add_filter('bp_activity_excerpt_length', 'px_bp_activity_excerpt_length');

    @skyseven7

    Participant

    Hi @marcella1981, I’ve posted my message too soon!
    What I would want to know is how to shorten the excerpt so that it wouldn’t flood the activity stream.

    Okay so I tried adding the code (thank you so much for that) and it worked but not as what I expect it to do.

    Is there a way to show only the excerpt and not the [read more] toggle link?

    @marcella1981

    Participant

    Hey,

    Yeah you can hide it with some CSS. There is a way you can do it with PHP but I couldn’t tell you how off the top of my head.

    span.activity-read-more { display: none; }

    @danbp

    Participant

    @skyseven7, @marcella1981

    there is a more elegant way to style SWA excerpt.
    The display css trick hides only things on frontend, for humans, but the data is still in the source. So if you don’t want to use it, you can also remove it from the logic, to spare a little server ressource, at least.

    For 2.0 and above, use these sinppets from within functions.php or bp-custom.php

    Filters the length (default length is 225 char)
    Reference: bp-core/bp-core-template.php:541

    function bpfr_custom_length( $excerpt_length) {
    	$excerpt_length = '200'; // change value to your need	
    	return $excerpt_length;  
    	
    } 
    add_filter( 'bp_activity_excerpt_length', 'bpfr_custom_length', 10, 1);

    Append text filter

    function bpfr_custom_append_text( $append_text) {
    	$append_text    =  'your append text here';
    		return $append_text;  
    } 
    add_filter( 'bp_activity_excerpt_append_text', 'bpfr_custom_append_text', 10, 1);

    @skyseven7

    Participant

    @marcella1981 and @danbp

    Thank you so much! Those codes worked out fine!

    Cheers!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] BP WordPress Activity Stream Excerpt Problem’ is closed to new replies.
Skip to toolbar