This topic has 6 replies, 3 voices, and was last updated 7 years by Radu.

  • Author
  • #153158
     Happiier
    Participant

    Good Day,

    I am trying to show all user posts in buddypress profile. You recommend Social Articles but I have two issues:

    1. Does not show Custom Post Types (CPT’s)

    2. The format doesn’t match Kleo theme well

     

    Is it possible to call user posts/CPT’s for given user profile to show in Kleo Masonry?

     

    I can create a new buddypress tab, I just need to know how what to add from Kleo theme.

     

    Thank you!

    Blaze

    #153266
     Laura
    Moderator

    Hello, will assign the ticket to a higher support level who can help and advise you in your query.
    Thanks! ?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #153541
     Radu
    Moderator

    Hi,

    You can pull posts from certain CPT’s using Kleo posts and build query function

    You can create new BuddyPress profile tab inspiring from here but you need to have some PHP knowledge: http://wordpress.stackexchange.com/questions/46279/im-trying-to-add-a-new-buddypress-menu-tab-and-it-is-not-showing-up

    Cheers
    R

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #153781
     Happiier
    Participant

    Thank you for your response. I found this code snippet which seems to be great! However, I am having an issue identifying which template part would work to display KLEO MASONRY posts for a given author. (see images)

    Can you please identify which .php file I should be calling or what to include in a new.php template.

    I have tried many existing as you can see in the images. None were exactly correct.

    With Gratitutde,
    Blaze

    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’ => ‘My Posts’,
    ‘slug’ => ‘posts’,
    ‘screen_function’ => ‘bp_postsonprofile’,
    ‘default_subnav_slug’ => ‘My Posts’,
    ‘position’ => 35
    )
    );
    }

    // 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( ‘member-posts’ );
    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

    }

    Attachments:
    You must be logged in to view attached files.
    #153793
     Happiier
    Participant

    Actually, projectwyld.com/author/authorname is exactly what I need to show.

    It has the appropriate Kleo Masonry in the correct columns. I just need for the main content area/post area to be called without the sidebar, footer, and socket as when I plug in archive.php in the code provided.

    Hope this helps.

    #153844
     Happiier
    Participant

    PLEASE SKIP AHEAD TO THIS REPLY!!!!!!!!!!!!!!!!!!!!!!!!

    I am super close and now only need simple advice. I used the following code and I am just about able to complete the process (SEE PHOTO). However, I need some help to get things in order.

    I am pretty sure that I need to make new template parts, but I need some clarity if this is correct. Thank you so much!!

    ———————————————————————————-

    Note: “bpawesome” = copy of Archive.php that I can modify.

    //POSTS ON PROFILE STARTS HERE

    add_action( ‘bp_setup_nav’, ‘add_profileposts_tab’, 100 );
    function add_profileposts_tab() {
    global $bp;
    bp_core_new_nav_item( array(
    ‘name’ => ‘My Posts’,
    ‘slug’ => ‘posts’,
    ‘screen_function’ => ‘bp_postsonprofile’,
    ‘default_subnav_slug’ => ‘My Posts’,
    ‘position’ => 25
    )
    );
    }
    // show feedback when ‘Posts’ tab is 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’ ) );
    }

    function profile_screen_posts_show() {
    query_posts( ‘author=’ . bp_displayed_user_id() );
    if ( have_posts() ) :
    get_template_part( ‘bpawesome’ );
    else:?>

    <p><?php bp_displayed_user_username(); ?> has not published any post! </p>

    <?php endif; ?> <?php

    }

    //POSTS ON PROFILE ENDS HERE

    Attachments:
    You must be logged in to view attached files.
    #153907
     Radu
    Moderator

    Hi the kleo post templates are located in kleo theme directory

    Most probably you will have to copy from example the content-audio.php file to child theme and to rename it to content-tabbuddypress.php and inside build your loop template and then form your snippet instead of calling get_template_part( ‘bpawesome’ ); you will have to call get_template_part( ‘content’, ‘tabbuddypress’ ); kind of

    Read here how the get template works https://konstantin.blog/2013/get_template_part/

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 7 posts - 1 through 7 (of 7 total)

The forum ‘Plugins questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?