Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom post types to activity


  • Unsal Korkmaz
    Participant

    @unsalkorkmaz

    Trying this code for adding custom post types to activity

    function firmasite_activity_publish_cpt( $post_types ) {
    	$post_types[] = 'yemek';
    	$post_types[] = 'foto';
    	return $post_types;
    }
    function firmasite_activity_publish_cpt_comments( $post_types ) {
    	$post_types[] = 'yemek';
    	$post_types[] = 'foto';
    	return $post_types;
    }
    add_action('save_post', function() {
    	add_filter( 'bp_blogs_record_post_post_types', 'firmasite_activity_publish_cpt',1,1 );
    	add_filter( 'bp_blogs_record_comment_post_types', 'firmasite_activity_publish_cpt_comments',1,1 );
    },8);

    I couldnt see where is problem.. Do we really need to create a function similar to `bp_blogs_record_post`?

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

  • shanebp
    Moderator

    @shanebp

    Your add_action is a mess.
    Try this:

    
    function firmasite_activity_publish_cpt( $post_types ) {
         $post_types[] = 'yemek';
         $post_types[] = 'foto';
         return $post_types;
    }
    add_filter ( 'bp_blogs_record_post_post_types', 'firmasite_activity_publish_cpt',1,1 );

    Unsal Korkmaz
    Participant

    @unsalkorkmaz

    yeah i tried that in first place


    shanebp
    Moderator

    @shanebp

    That approach is the proven standard.
    Here’s a thread on it:
    https://buddypress.org/support/topic/display-custom-post-types-in-activity-feed/

    You don’t say where you’re trying that code.
    So it might be the file location or maybe something in how you built the cpts.


    Unsal Korkmaz
    Participant

    @unsalkorkmaz

    I tried code in bp-custom.php  and in mu-plugins file. I tried to attach it to init and save_post too as you see in above


    Unsal Korkmaz
    Participant

    @unsalkorkmaz

    Well..
    I found my problem..
    Btw it seems it was a misunderstood that i was trying to show it on blogs directory as latest post.. Seems my problem is post_type = ‘post’ is hardcoded on buddypress:

     $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );
    

    This is just.. wrong. Why not use {$blog_prefix}bp_activity table? why trying to connect to {$blog_prefix}posts?


    Unsal Korkmaz
    Participant

    @unsalkorkmaz


    EQThinkLab
    Participant

    @eqthinklab

    hey unsal, trying to do the same thing with no luck. tried all the solutions in these discussions and cant make custom post type show up on activity stream. can you share the code changes/adds you did in order to make it work?

    thanks in advance!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom post types to activity’ is closed to new replies.
Skip to toolbar