New
PeoplePress is here. Community building for WordPress, reimagined. Fast, modern, and built for the communities you've always wanted to run.
See it live

BuddyDev

Search

Displaying title and user on shortcode pages

  • Participant
    Level: Initiated
    Posts: 10
    Xochi on #7154

    Greetings,

    I would like the title and the user name (with link on user) to appear under the thumbnail of media or gallery on pages I create with shortcode.

    I have been able to get the name and media to appear on media pages, but not on pages that contain galleries.

    This is the code I added to functions.php file:

    add_action( ‘mpp_after_media_shortcode_item’, ‘mpp_media_title’ );
    add_action( ‘mpp_after_media_shortcode_item’, ‘mpp_custom_add_user_link’ );
    function mpp_custom_add_user_link() {
    //you may put some conditions here like

    //mpp_is_single_gallery();
    //mpp_is_single_media();
    //to avoid showing it on single gallery/media pages

    $user_id = mpp_get_media_creator_id();
    $link = sprintf( “%s“, bp_core_get_user_domain( $user_id ), bp_core_get_username( $user_id ) );
    echo $link;
    }

    add_action( ‘mpp_after_gallery_shortcode_entry’, ‘mpp_custom_add_user_link’ );

    Nothing changes on my gallery grid page. On my page with media grid where previously only the thumbnail showed up, I now get the title of the media and next to it the user_id with no space between the two. I would like the user name to appear below the title. And I would prefer the user name over the user id.

    Thanks,
    Xochi

  • Keymaster
    (BuddyDev Team)
    Posts: 25509
    Brajesh Singh on #7162

    Hi Xochi,
    I am sorry for the inconvenience. which shortcode are you using ?

    is it

    [mpp-show-gallery] or is it
    [mpp-list-media]

    They use different templates, so the hooks are a little bit different. Also, The first should show the title automatically.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 10
    Xochi on #7164

    Hi Brajesh

    This is the shortcode for galleries:

    [mpp-list-gallery type=audio]

    And this is the shortcode individual files in a gallery:

    [mpp-show-gallery id=380]

    This second one here I believe is the one you said titles should so up for. They did not until I added this to my functions.php file:

    add_action( ‘mpp_after_media_shortcode_item’, ‘mpp_media_title’ );

    Thanks,
    Xochi

  • Keymaster
    (BuddyDev Team)
    Posts: 25509
    Brajesh Singh on #7167

    Hi Xochi,

    Thank you

    The fist displays the gallery title without any issue.

    The second had an issue. It was not loading the correct template. I have fixed it now on our development repo
    https://github.com/buddydev/mediapress/commit/1822fc6a598520e784935d2c9e9816296b438698

    Will push to wprog in next 2-3 days(this weekend, by Sunday).

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 10
    Xochi on #7173

    Hi Brajesh,
    Thank you. Will this also solve the problem of adding the user name in the manner I inquired of originally?
    Thanks,
    Xochi

  • Participant
    Level: Initiated
    Posts: 10
    Xochi on #7276

    Hi Brajesh,
    I still have my original question at the beginning of this thread of how to get the user name to display below a gallery when creating a page using shortcodes.
    Xochi

  • Keymaster
    (BuddyDev Team)
    Posts: 25509
    Brajesh Singh on #7286

    Hi,
    Please use the code from here

    
    
    /**
     * Display the name of the creator of the gallery below gallery cover
     *
     */
    function mpp_custom_display_gallery_owner_name() {
    	$gallery = mpp_get_gallery();
    	if ( ! $gallery ) {
    		return ;
    	}
    	printf(  'by: %s',  bp_core_get_userlink( $gallery->user_id ) );
    }
    add_action( 'mpp_gallery_shortcode_item_meta', 'mpp_custom_display_gallery_owner_name' );
    
    

    For other cases, you may take a look at the code here
    https://gist.github.com/sbrajesh/b47b84c3fdca9b76f04e696894a80d06

    We will be pushing the changed code(sorry, we missed the last deadline), hopefully this sunday too.
    Thank you. We will keep you informed.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 10
    Xochi on #7972

    Greetings Brajesh,

    I am still not getting the name of the gallery owner on a page of galleries created with short code. The name does now however show up in the lightbox.

    Xochi

  • Keymaster
    (BuddyDev Team)
    Posts: 25509
    Brajesh Singh on #7977

    Hi Xochi,
    I am not sure of the issue. I am going to ask @ravisharma to take a fresh look at this and see if he can help here.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 22
    Ryan Mckernan on #8639

    I am also interested in adding the name to the site wide gallery, It currently only shows the gallery title “wall photo gallery” I am happy with the functionality. I would just like users to be able to see who’s gallery they are looking at with out have to open it.

    If the code above is correct , where would I add it to ?

The topic ‘Displaying title and user on shortcode pages’ is closed to new replies.

This topic is: not resolved