Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of hnla

Get Each Blogs Description (13 posts)

Started 1 year, 8 months ago by: joshmac

  • Profile picture of joshmac joshmac said 1 year, 8 months ago:

    In the blogs directory, I am trying to show each blog’s description either by updating it in the bp_ table or by using the filter to get it. I am having an issue with doing the later and was hoping to get a little help. Below is what I have so far.

    function get_users_blog_description() {
    $description = get_blog_option($blog_id, ‘blogdescription’);
    return $description;
    }
    add_filter(‘bp_blog_description’, ‘get_users_blog_description’,10,2);

  • Profile picture of joshmac joshmac said 1 year, 8 months ago:

    Can anyone help me out with this?

  • Profile picture of joshmac joshmac said 1 year, 8 months ago:

    Please disregard, I wrote a quick sitewide plugin that handles this.

  • Profile picture of @mercime @mercime said 1 year, 8 months ago:

    @parkstreet – will you be sharing this plugin :-)

  • Profile picture of Brandon Allen Brandon Allen said 1 year, 8 months ago:

    @parkstreet
    In case you want to give it a try later, the reason the filter didn’t work is because of the fourth parameter in add_filter(‘bp_blog_description’, ‘get_users_blog_description’,10,2). The fourth parameter is for the number of accepted arguments. The number of accepted arguments is determined by the number of arguments passed by the corresponding apply_filters(). In the case of ‘bp_blog_description’, only one argument is passed, which is the blog description. However, you are telling the add_filter() function that apply_filters() is sending two arguments its way, which in turn causes it to fail when it only receives one. The fourth parameter defaults to one, which is what you want for your example, so

    add_filter(‘bp_blog_description’, ‘get_users_blog_description’,10);

    should do the trick.

  • Profile picture of r-a-y r-a-y said 1 year, 8 months ago:

    @parkstreet – I think you’re making this way too complicated!

    The easiest way is to copy over the /blogs/blogs-loop.php to your child theme and use the template tag: bp_blog_description() somewhere in the loop.

    There’s an action to hook into in the bp-default template, but the hook is after the last activity block, which is probably not where you want the blog description to show up.

  • Profile picture of joshmac joshmac said 1 year, 8 months ago:

    I think I may have been a little unclear about what I am trying to do. I don’t want the blog’s description that is currently in the wp_bp_user_blogs_blogmeta table. I want the blog description that was entered in wp_{blog_id}_options table for each blog. The bp_blog_description tag works whether I copy over the file to the child theme or not. So what my plugin does is allow each blogger to update the buddypress table that corresponds with the current blog with a 250 character description of that blog.

    @mercime, at some point I will. But at the moment I don’t feel comfortable sharing it because it was just a quick and dirty (yet secure) solution for me. Once I clean it up and test it more thoroughly, I will release it if people are really interested in a plugin like this. But maybe someone else has a better solution to be able to tap into each blog’s options table to pull the blog description. On second thought, maybe there isn’t a way and that is why the buddypress blog meta table exists in the first place.

  • Profile picture of r-a-y r-a-y said 1 year, 8 months ago:

    @parkstreet – Gotcha!

    Looks like this issue has been reported:

    http://trac.buddypress.org/ticket/2415

  • Profile picture of joshmac joshmac said 1 year, 8 months ago:

    Ah, I see. I’ve never noticed it before so did not think it was a bug. Thanks @r-a-y for bringing that to my attention.

  • Profile picture of slaats slaats said 1 year, 7 months ago:

    Joshmac and BP community -
    I put a vote in for seeing a plugin that displays a description in the blog directory.

  • Profile picture of justbishop justbishop said 1 year, 6 months ago:

    bump! Share the plugin? Pretty please?

  • Profile picture of r-a-y r-a-y said 1 year, 6 months ago:

    Refer to my post above:

    http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/get-each-blogs-description/#post-57524

  • Profile picture of justbishop justbishop said 1 year, 6 months ago:

    Aha! Thanks ;)