I am using the Media Library Categories plugin. It does not have much documentation, so I have concluded the way to implement it would be using the shortcode [mediacategories categories="6"]
.
I want to implement this directly into the theme template. So I have tried:
<?php if(function_exists(do_shortcode('[mediacategories categories="6"]'))) { ?>
<h1>Inspiration</h1>
<?php
do_shortcode('[mediacategories categories="6"]');
}
I also tried to implement the function directly, but could not pass the $atts correctly for the function to use them.
do_shortcode()
just parses the string. You have to useecho
orprint
to print it out.function_exists()
expects a string that matches a function name. After looking at the plugin, I would try this code:I usually add a section like this to my shortcode callbacks:
This enables you to pass a ‘primary’ attribute (replace
primary_att
with whatever you primary attribute is called) directly into the function, without wrapping it in an array…in your case it could be ‘categories’ and you could call it likemediacategories_func(6);
then.