-
Author
-
February 21, 2017 at 23:33 #153769HappiierParticipant
Hello Wonderful Kleo Support!!!
I have a simple question but need your direction. Using the code below, I have successfully created a new buddypress tab to show all posts by a given author. My goal is to have this tab show KLEO MASONRY of that author’s posts/custom posts.
I have plugged in many different page parts, but none have really worked and the ‘archive.php’ doesn’t work either (see images).
Can you please help me to select or create a simple php file that would work to show KLEO MASONRY for posts by the author of a given profile.
Thank you so much!!
Blaze
PS- I am intentionally avoiding Social Articles Plugin.
Images are of Buddypress tab with three different .php parts: Archive.php, Content.php, and Full-Width.php
Attachments:
You must be logged in to view attached files.February 21, 2017 at 23:35 #153774HappiierParticipantAnd here is the code:
// Display posts in user profile
// Construct new user profile tab
add_action( ‘bp_setup_nav’, ‘add_profileposts_tab’, 100 );
function add_profileposts_tab() {
global $bp;
bp_core_new_nav_item( array(
‘name’ => ‘Awesome’,
‘slug’ => ‘awesome’,
‘screen_function’ => ‘bp_postsonprofile’,
‘default_subnav_slug’ => ‘My Posts’,
‘position’ => 10
)
);
}// show ‘Posts’ tab once clicked
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’ ) );
}// query the loop and get the template
function profile_screen_posts_show() {
$user_id = bp_displayed_user_id();
$query = new WP_Query( ‘author=’ . $user_id );if ( $query->have_posts() ) :
while ( $query->have_posts() ): $query->the_post();
// fill in your template part here, if you have another template than member-posts.php
get_template_part( ‘post-content-masonry’ );
endwhile;else: ?>
// if the author hasn’t made any posts, display this message
<p><?php bp_displayed_user_username(); ?>’s hasn’t made any posts yet! </p><?php endif; wp_reset_postdata();?> <?php
}
-
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.