CPT Listing in BP profile
-
I use this snippet below for showing user posts with BP Profile, which works fine.
I like to show within this tab CPT posts too. The CPT slug is „bullishow“.add_action( 'bp_setup_nav', 'add_profileposts_tab', 100 ); function add_profileposts_tab() { global $bp; bp_core_new_nav_item( array( 'name' => 'Beiträge', 'slug' => 'posts', 'screen_function' => 'bp_postsonprofile', 'default_subnav_slug' => 'My Posts', 'position' => 35 ) ); } function bp_postsonprofile() { add_action( 'bp_template_content', 'profile_screen_posts_show' ); bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) ); } function profile_screen_posts_show() $myposts = get_posts( array( 'posts_per_page' => -1, 'author' => bp_displayed_user_id(), 'post_type' => 'post' )); if( ! empty($myposts) ) { echo '<ul>'; foreach($myposts as $post) { setup_postdata( $post ); echo '<li><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></i>'; } echo '</ul>'; wp_reset_postdata(); } else { echo '<div class="info" id="message"><p>'. bp_displayed_user_fullname() .' hat keine Beiträge veröffentlicht.</p></div>'; } } add_action ( 'profile_screen_posts_show' );
- You must be logged in to reply to this topic.