我使用自定义的帖子类型,我将在我的BuddyPress活动feed中显示。我能够设置帖子类型在提要中工作,但我无法找到关于如何在提要中显示标题的文档。这是我的代码,我想显示[title]
的帖子标题:
add_post_type_support( 'news', '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( 'news', array(
'component_id' => buddypress()->blogs->id,
'action_id' => 'new_news_item',
'bp_activity_admin_filter' => __( 'News', 'custom-domain' ),
'bp_activity_front_filter' => __( 'Pages', 'custom-domain' ),
'contexts' => array( 'activity', 'member' ),
'activity_comment' => true,
'bp_activity_new_post' => __( '%1$s - <a href="%2$s">News: [title]</a>', 'custom-textdomain' ),
'bp_activity_new_post_ms' => __( '%1$s - <a href="%2$s">News: [title]</a>, on the site %3$s', 'custom-textdomain' ),
'position' => 100,
) );
}
add_action( 'bp_init', 'customize_page_tracking_args' );
在这行代码中,我可以看到%1$s
是用户名,%2$s
是帖子链接。BuddyPress中是否有更多这样的片段,我可以使用,特别是一个帖子标题?
'bp_activity_new_post' => __( '%1$s - <a href="%2$s">News: [title]</a>', 'custom-textdomain' ),
谢谢你的帮助!
您可以在BuddyPress.org网站上阅读此法典页面。它有更多的信息,并描述了如何加强CPT和BuddyPress活动提要之间的连接。示例如下: