Skip to:
Content
Pages
Categories
Search
Top
Bottom

Assigning Post Title to (Post Type) Title in Activity


  • homelesshenry
    Participant

    @homelesshenry

    I’ve followed the guide at:

    Post Types Activities

    And I’ve made woocommerce products appear in the activity stream via the code below:

    <?php
    
    add_post_type_support( 'product', '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( 'product', array(
            'component_id'             => buddypress()->blogs->id,
            'action_id'                => 'new_product_page',
            'bp_activity_admin_filter' => __( 'Published a new product', 'custom-domain' ),
            'bp_activity_front_filter' => __( 'Pages', 'custom-domain' ),
            'contexts'                 => array( 'activity', 'member' ),
            'activity_comment'         => true,
            'bp_activity_new_post'     => __( '%1$s posted a new <a href="%2$s">product</a>', 'custom-textdomain' ),
            'bp_activity_new_post_ms'  => __( '%1$s posted a new <a href="%2$s">product</a>, on the site %3$s', 'custom-textdomain' ),
            'position'                 => 100,
        ) );
    }
    add_action( 'bp_init', 'customize_page_tracking_args' );
    
    ?>

    What I’m trying to do is make it so the Product Post Title appears hyperlinked instead of a static word (in this case, “Product”):

    'bp_activity_new_post' => __( '%1$s posted a new <a href="%2$s">product</a>', 'custom-textdomain' ),

    I don’t know PHP, so I thought I might be able to just jam something similar I’ve found to replace that line of code, such as:

    sprintf( __( '%1$s created a new Product post, %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '' . $post->post_title . '' );

    Unfortunately, that doesn’t work.

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