[wp-hackers] Attaching files to posts
Tobias Davis
tobias at davistobias.com
Fri Apr 29 05:15:31 UTC 2011
Hello all, I have a question about how to store URLs for posts.
I'm making a plugin which manages audio files attached to sermons, basically
just files attached to a custom post type.
The plugin which I am replacing (an outdated and abandoned plugin)
essentially creates it's own set of database tables, essentially mirroring
the WP database structure. It has an option to link external URLs to a
sermon, and in the templating it then uses a single function to display any
file, either internal or external. Because of this, the person making the
template can just use something like "show_files()", and it will show files,
whether they are on the server or external URLs. (It actually uses
shortcodes, and some internal templating things.)
I am trying to recreate a similar approach, using built-in WordPress
functions, so that the designer can use things like has_post_thumbnail, and
so on.
Of course, I can attach files normally and store URLs in the post meta, but
then a template theme would need to do something like if( has_files() ||
has_whatever_postmeta(); My goal is to make the URL somehow seamlessly the
same as normally attached files, so far as themes are concerned.
Any input/critique on this problem would be helpful, but I did wonder if I
could just add the "files" into the database, manually if required, and set
the guid to the external link? Are there any dangers/problems to this
approach?
Thanks for any thoughts/critiques,
-----Tobias
More information about the wp-hackers
mailing list