What I want to achieve is to add vCards to my contact pages, created on the fly and downloadable. I guess I could make a very bare template with the functionality and the correct mime-settings to the header etc, add a page (which is never displayed as it is) to get an address and call it with the ID of the current contact in a querystring. I'm pretty sure that would work, but it feels instinctively wrong.

The other way to do it would be to create a proper static file, as you would outside of a CMS, and, when called, let it look through the database. But this seems even more wrong.

So what would be the proper way to do something like this?

This time, my hope is to make a vCard solution, but based on my previous experiences (mainly from ASP and custom built CMSes) similar things comes up every now and then - maybe you need a downloadable XML-file based on something in the database or a slightly dynamic css/js file based on a setting (like an AJAX file with proper references to the theme or what not).

  • 1
    I created a similar solution that uses a template which simply grabs the relevant information from the specified post ID and then echos it in the correct format. That works well, and has for a several years. Obviously the way I grab the information will be different, but I'm happy to share the code if you wish.
    – David Gard
    Jan 2, 2014 at 16:04
  • @DavidGard Thanks! That's how I've done similar things before, it just seems like we're taking a bit of a detour and it's not a very pretty solution.
    – Linda H
    Jan 2, 2014 at 16:23
  • But as you mentioned yourself, the only other way to do it is to create a vCard for every contact. Not only will that required multiple files, all of which will have to be painstakingly linked to the relevant contact, but you'll just end up spending lots of time on maintaining them. The whole idea of PHP (and other web languages) is to make websites dynamic, not static, and although the actual source may not look pretty, it'll likely be far more efficient than the alternative.
    – David Gard
    Jan 2, 2014 at 16:31
  • @DavidGard Oh, absolutely! What you describe is what my (non-coder) colleagues wanted to do in the first place. I was just thinking there must (or at least should) be a better way that I, still being relatively new to the world of PHP/WP, wasn't aware of and I figured if there was, people here would know :D
    – Linda H
    Jan 2, 2014 at 16:59
  • add a rewrite endpoint, see this answer.
    – Milo
    Jan 2, 2014 at 17:35


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.