Skip to:
Content
Pages
Categories
Search
Top
Bottom

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

  • Avatar of Seppolaatle112
    seppolaatle112
    Participant

    @seppolaatle112

    Hi everyone, and congratz to you Andy with versjon 1.0 of Buddypress. I have been watching the Buddypress developement since about November, 2008, and I must say I really do love everything you have created! :)

    Now, I actually have two small questions about the Recent Blog Posts widget witch is showing the latest blogposts all across the network. Number 1 could be easy I guess, but I would like a little “how-to-guide” if anyone of you guys can help me.

    1: How can I limit the excerpt in the widget, to only show a sprecified number of charachters,? Note.: Not words, but charachters.?

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

    That’s it! Any help on my 2 small questions would be appriciated.! :)

    Regards

    Atle Grimseid

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of Jeff Sayre
    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.

    Avatar of Seppolaatle112
    seppolaatle112
    Participant

    @seppolaatle112

    Sorry for my late reply in this thread!

    Jeff, thanks for giving me some helping hints to my questions.!

    Actually, I knew about the bp-core-templatetags.php and the bp_excerpt function, but as far as I can see this one only give me the opportunity to specify the lengt of the excerpt in words, and not charachters. The bad thing about this is that some words are some kind of loooooooong, and that is just… bad… :( So if there is anything I can do to actually specify the lenght in number of characters that would be perfect.. ? :)

    I am afraid I can’t find any solution to my Q nr 2, but it’s really not a big deal. I’ll manage just fine by having the main blog post’s in the widget.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.