It’s good to hear you are finding MLA useful; thanks. I think I understand your question, but I want to expand on it to make sure I get it right.
When you say ‘all images from the “Sport” category‘, I assume you went to the Settings/Media Library Assistant General tab and checked the Support box for the Categories taxonomy. Then, you assigned one or more attachments to the Sport category. If that’s right, your category_name='sport'
parameter should work, although it’s possible that the missing “]” at the end of your shortcode is causing trouble.
When you say “want to get URL of all images” do you really mean just the URL, e.g., http::mysite.com/wp-content/uploads/my-image.jpg
? your example uses echo
to add the results of your shortcode to the page, so you might want a complete hyperlink instead, e.g.:
<a href="http::mysite.com/wp-content/uploads/my-image.jpg">My Image</a>
If you want a list of hyperlinks, you probably want some HTML around it such as an unordered list (< ul >
). You can use the a custom template to customize the HTML or just add itemtag
, icontag
and captiontag
parameters to the shortcode. For example, to change the gallery markup to use div, span and p tags: [mla_gallery itemtag="div" icontag="span" captiontag="p" columns=1]
. Here’s an earlier support topic with more ideas:
Simple List
If you really want “raw” URLs, you can try something like this in your PHP code:
$gallery = do_shortcode( '[mla_gallery category_name="sport" size=full link=none mla_style=none]' );
$count = preg_match_all( '/src=\"([^\"]*)\"/', $gallery, $mla_matches );
if ( $count ) {
foreach ( $mla_matches[1] as $match ) {
echo sprintf( '<meta property="og:image" content="%1$s" />', $match ) . "\n";
}
}
That last echo
statement can be replaced with anything you want to do with the URLs returned from the preg_match_all
function. The code above is adapted from this earlier topic which may give you other ideas as well:
Pull Featured Image from MLA Gallery
I hope that gives you what you need for your application. I will leave this topic unresolved until I hear back from you in case I have not understood your question. Thanks for your interest in the plugin.