Display media with a particular title

Hello,

I would like to display in a rtmedia gallery all the medias whose title is “Mainim” only. Is it possible to do a query on the name, with ‘rtmedia-model-where-query’? I have seen this code for rtmedia query on media_ids :

https://rtmedia.io/docs/addons/bbpress-attachments/developers/custom-code-display-particular-media-rtmedia_gallery-shortcode/

but I don’t know how to adapt it for titles, and what field instead of media_ids I should use.

Thanks a lot, Marine

Hello @marine,

There is not any direct option available for this. It will require some custom coding in order to add a new parameter for the media name in the shortcode.

However, I can guide you with a sample code which will give you direction for your custom code.

Please, refer below code: https://gist.github.com/rahul3883/34f4e03957bf6ee93677006e0f6b0f6d

Here is the usage example:

[rtmedia_gallery media_name="example"]

I hope this helps you.

Thank you.

Hello @pranalipatel, Thank you very much and sorry for the delay. I tried to add the code snippet in functions.php but when I add it the website appears as a blank page everywhere (with no error in the console). I don’t know from where is the error. Thanks, Marine

Hello @marine,

It should work properly. Please, make sure you have removed the <?php tag from the starting of the code.

Additionally, please check if you are getting any error in your server error log.

Thanks