我正在使用自定义的post类型,我将在我的BuddyPress活动提要中显示这些类型。我可以将帖子类型设置为在提要中正常工作,但我找不到有关如何在提要中显示标题的文档。以下是我的代码,我想要显示帖子标题,其中[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是post链接。在BuddyPress中,我是否可以使用更多这样的代码片段,特别是用于帖子标题的代码片段?
'bp_activity_new_post' => __( '%1$s - <a href="%2$s">News: [title]</a>', 'custom-textdomain' ),谢谢你的帮助!
发布于 2015-08-09 06:51:36
您可以在BuddyPress.org站点上阅读此Codex页面。它有更多的信息,并描述了如何加强CPT和BuddyPress活动提要之间的连接。Here就是一个例子。
https://stackoverflow.com/questions/31814393
复制相似问题