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,
XochiHi 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
BrajeshHi 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,
XochiHi 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/1822fc6a598520e784935d2c9e9816296b438698Will push to wprog in next 2-3 days(this weekend, by Sunday).
Thank you
BrajeshHi,
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/b47b84c3fdca9b76f04e696894a80d06We will be pushing the changed code(sorry, we missed the last deadline), hopefully this sunday too.
Thank you. We will keep you informed.Regards
BrajeshHi 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
BrajeshI 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.