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.

2 Answers
2

do_shortcode() just parses the string. You have to use echo or print to print it out.

function_exists() expects a string that matches a function name. After looking at the plugin, I would try this code:

<?php
if ( function_exists( 'mediacategories_func' ) )
{
?>
<h1>Inspiration</h1>
<?php
    print mediacategories_func( array( 'categories' => 6 ) );
}

Leave a Reply

Your email address will not be published. Required fields are marked *