Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get Each Blogs Description


  • joshmac
    Participant

    @parkstreet

    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);

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

  • joshmac
    Participant

    @parkstreet

    Can anyone help me out with this?


    joshmac
    Participant

    @parkstreet

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


    @mercime
    Keymaster

    @mercime

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


    Brandon Allen
    Participant

    @cnorris23

    @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.


    r-a-y
    Keymaster

    @r-a-y

    @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.


    joshmac
    Participant

    @parkstreet

    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.


    r-a-y
    Keymaster

    @r-a-y

    @parkstreet – Gotcha!

    Looks like this issue has been reported:
    https://trac.buddypress.org/ticket/2415


    joshmac
    Participant

    @parkstreet

    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.

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

    bump! Share the plugin? Pretty please?


    r-a-y
    Keymaster

    @r-a-y

    Aha! Thanks ;)

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Get Each Blogs Description’ is closed to new replies.
Skip to toolbar