I need your recommendation for the best practice here:
- A custom post type I have created needs a list of attachments at the end of the post content.
- I have created a series of functions that handle displaying the list of appropriate attachments for a post.
- I don't want to use shortcode to insert this attachment list, since every post of this post type should have the list
- I'm looking for a portable, reusable approach
My initial approach was to encapsulate the attachment functions into a standalone plugin. But how to integrate the plugin output into the page if I don't use shortcode?
My solution was to create my own pseudo-template-tag ("the_attachments()") which is defined in the plugin. Then my custom-post-type.php template page uses this pseudo-template-tag right after the_content() and we get our nice list.
But is this really the best approach? Now we have a template that's dependent on an external plugin. If the plugin isn't there, the template "breaks". It's tough to "require" a plugin, from a template perspective because is_plugin_active() is only available at the admin level, and that's probably for a reason (because it's a stupid idea to make a template dependent on a plugin!)
So I'm left with either: A) decouple the plugin output from the template, similar to the way a widget works (if so, how do I pass the $post information to that widget?), or B) embed the "plugin" code within the template functions (but is this then truly portable?)