Skip to:
Content
Pages
Categories
Search
Top
Bottom

Latest post from blogs duplicates record after delete

  • Avatar of yu
    yu
    Participant

    @gerbilo

    After delete post in blog i got strange duplicate on my front page in widget ‘Latest posts from blogs’ -> http://tf2.lv

    I’ve allready used this function to add DISTINCT for unique record in this widget.. so now i just dunno what to do.. please help (

    function get_latest_posts( $blog_id = null, $limit = 5 ) {
    global $wpdb, $bp;
    if ( $blog_id )
    $blog_sql = $wpdb->prepare( " AND p.blog_id = %d", $blog_id );
    $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT p.post_id, p.blog_id FROM " . $bp['blogs']['table_name_blog_posts'] . " p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 $blog_sql ORDER BY p.date_created DESC LIMIT $limit" ) );

    for ( $i = 0; $i < count($post_ids); $i++ ) {
    $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
    }

    return $posts;
    }

Viewing 5 replies - 1 through 5 (of 5 total)
  • Avatar of yu
    yu
    Participant

    @gerbilo

    i’ve tryied to add p.post_type = ‘post’ and p.post_status = ‘publish’.. but all i got it’s blank screen ((

    Avatar of yu
    yu
    Participant

    @gerbilo

    this bug pops up only when NON-author deletes post in blog. for example user ‘a’ makes some blog entry, and ‘admin’ deletes it.

    Avatar of yu
    yu
    Participant

    @gerbilo

    we got it! problem is in the ‘function delete’ in bp-blogs-classes.php

    origin ->

    return $wpdb->query( $wpdb->prepare( “DELETE FROM ” . $bp . ” WHERE user_id = %d AND blog_id = %d AND post_id = %d”, $user_id, $blog_id, $post_id ) );

    edited one ->

    return $wpdb->query( $wpdb->prepare( “DELETE FROM ” . $bp . ” WHERE blog_id = %d AND post_id = %d”, $blog_id, $post_id ) );

    Avatar of Jvinch
    jvinch
    Participant

    @jvinch

    We should really make sure these bugs and fixes make it to trac so they’re not missed by Andy and his crew.

    Avatar of yu
    yu
    Participant

    @gerbilo

    oh.. yeap.. i’ll create a few tickets lately ))

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

You must be logged in to reply to this topic.