5

I need to use an existing database table as a Custom Post Type (CPT) to integrate it with wordpress.

I've considered @boone-gorges thoughts here (should I?) and have decided, Yes, I need to use a custom table (mostly for indexing of the 20+ "custom meta" fields that would get bogged in wordpress' native handling of custom meta.)

Aside from home-grown display and usage of data, I need tight integration with Wordpress (acts and behaves like CPT) so that I can:

Editing / Updating through WP would be a bonus - though not necessary (the table will be edited mostly via external programs, which is another reason it needs to be separate).

Is there a slick way to make this happen? Perhaps implementing hooks that hijacks calls to that CPT and directs them to the other table?

I'm looking at Pods - but this seems like overkill.

2
  • When you take a Corolla and you it to run like a Jaguar someone will pull their hair at some point. Wordpress is designed to work in a certain way and I suggest for the sake of future updates that you tweak your algorith a little. For instance the reason the CPT functionality came along was so that we don't use other tables unnecessarily. I think you should think along those lines
    – Janvier
    Commented Jul 31, 2014 at 5:17
  • Circling back to this... I abandoned WordPress altogether for this task, and am using a NextJs on a custom database to achieve what I wanted. WordPress isn't always the right tool for the job. (Though it is 90% of the time ;-)) Commented Nov 15, 2020 at 2:03

1 Answer 1

3

My educated guess you will drown in edge cases, exploding in your face, if you try to shard specific post type in separate table.

Since you seem to be actually concerned with meta rather than posts themselves, you could:

  • implement custom table for it
  • use Metadata API to store it in separate table, while retaining some degree of API compatibility.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.