Skip to:
Content
Pages
Categories
Search
Top
Bottom

use permalink in custom post activity


  • brianhackett
    Participant

    @brianhackett

    Hi Guys
    Im using custom post activities to pull in rss feeds into user activity feeds. I use wp rss aggregator and feedtopost to create a custom posts feed from other social networks which i can then assign to individual members. So at the moment I have pull in the feed excerpt as a title and the featured image into the feed using this code

    <?php
    // Don't forget to add the 'buddypress-activity' support!
    add_post_type_support( 'social_feed', 'buddypress-activity' );
    function customize_page_tracking_args() {
        // Check if the Activity component is active before using it.
        if ( ! bp_is_active( 'activity' ) ) {
            return;
        }
        bp_activity_set_post_type_tracking_args( 'social_feed', array(
            'component_id'             => buddypress()->blogs->id,
            'action_id'                => 'new_social_feed',
            'bp_activity_admin_filter' => __( 'My Social Feed', 'custom-domain' ),
            'bp_activity_front_filter' => __( 'Social Feed', 'custom-domain' ),
            'contexts'                 => array( 'activity', 'member' ),
            'activity_comment'         => true,
            'bp_activity_new_post'     => __( '%1$s posted a new <a href="%2$s">Social Media Update</a>', 'custom-textdomain'  ),
            'bp_activity_new_post_ms'  => __( '%1$s posted a new <a href="%2$s">Social Media Update</a>, on his profile', 'custom-textdomain' ),
            'position'                 => 100,
        ) );
    }
    
    add_action( 'init', 'customize_page_tracking_args', 1000 );
    
    // Adds title of custom Blog Post Type instead of excerpt
    
    function record_cpt_activity_content( $cpt ) {
    
        if ( 'new_social_feed' === $cpt['type'] ) {
    
            $cpt['content'] = get_the_title();
        }
    
        return  $cpt;
    }
    add_filter('bp_after_activity_add_parse_args', 'record_cpt_activity_content'); 
    
    // Adds custom blog featured image to activity feed
    function record_cpt_activity_content_featured_image( $cpt ) {
    
        if ( 'new_social_feed' === $cpt['type'] ) {
    
            global $wpdb, $post, $bp;
            $theimg = wp_get_attachment_image_src(  get_post_thumbnail_id( bp_get_activity_secondary_item_id() ) );
            $cpt['content'] .= '<img src="' . $theimg[0] . '" width="160px" height="30px">';
        }
    
        return $cpt;
    }
    add_filter('bp_after_activity_add_parse_args', 'record_cpt_activity_content_featured_image');
    ?>

    This works well but i would like to add a link back to the original social media post.I have setup wp rss aggregator to add the original link as the permalink for each of the custom posts.So I wanted to know how to work the permalink in so the title and image are linked back to the original post.
    Thanks

  • You must be logged in to reply to this topic.
Skip to toolbar