Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: 2 questions about the \\\\\\\”Recent Blog Posts-widget.\\\\\\\”


Jeff Sayre
Participant

@jeffsayre

Atle-

First of all, I would recommend copying the Recent Blog Posts widget and modifying the copy. Otherwise, the next time you upgrade BuddyPress, your changes will be gone. When done, place your new widget in /mu-plugins/. Call it something different so that you can easily recognize it in WPMU’s backend.

Okay, now the code changes:

  1. How can I limit the excerpt in the widget

    If you look in that widget, you’ll see that the function bp_create_excerpt() is called to create the excerpt. This function is located in bp-core-templatetags.php. The number of characters is determined in the function’s arguments.

    Copy that function, place it in your new widgets file, and rename it. Change the number of characters to your desired limit. Then make sure you reference the new function instead

  2. Is there anything I can do to exclude the main blog from this widget?

    In the widget, the fucntion bp_blogs_get_latest_posts() is called. This function is located in bp-blogs.php. It relies on a method get_latest_posts() located in bp-blogs-classes.php.

    Thinking out loud, I suppose you could set up a variable that excludes the Admin blog and pass it as a parameter into the bp_blogs_get_latest_posts(). The other option is to create a custom class and method and rewrite the query to exclude the main blog.

    Haven’t tried either. So, I’m not sure the best approach.

Skip to toolbar