0

Wordpress (with plugin for Custom Fields stored at DB Custom table like Pods/MetaBox/JetEngine/etc)

Logic:

  1. Custom Post Type (CPT) witch data will be stored at database Custom Table.
  2. Custom Taxonomy with Custom Terms.
  3. Adding to CPT Metabox Custom Fields with possibility to multi-choose of #2.

Example:

  1. CPT "Cars".
  2. Custom Taxonomy "Material" with Terms: "Metal, Plastic, Rubber".
  3. On CPT "Cars" a new post "Audi" creating there are appear a list of Custom Fields, for example field "Material" with values taken from Taxonomy "Material". User can choose 1 like "Metal" or many Terms at once like "Metal, Rubber" etc.

Question: How is better to store chosen Terms ID's at Database? But, please, take into account, that this "relationship" type is ONLY 1-side (DON'T need to choose CPT at Taxonomies!). I see next options:

A) Store at #1 database Custom CPT table at column like "materials_ids" all chosen ID's as comma separated text. But then is the question - which database column type is better for such purpose (varchar/tinytext/etc)? B) Or for such case the better DB design to create a new relationships table? But does it really needs for only 1-side relationship?!

What pros/cons between A/B methods for DB, WP, data using, searching, etc?

1
  • 1
    The questions a little difficult to understand, can you edit it to make it easier to read? The title makes no sense in english. I tried to add paragraphs but I could only get so far. Also are you aware of hierarchical terms? Parent/child terms? Modifying WordPress core tables is a big mistake and will lead to data being destroyed when WordPress updates and resets the tables back Commented Aug 22, 2023 at 9:20

1 Answer 1

0

If I am understanding right, you're suggesting creating separate database tables both for your post type and taxonomies. You don't really need to do that at all. Just create a custom post type which WordPress will store in the {prefix}_posts table, and create a custom taxonomy for that post type which WordPress will also handle in its native tables. It's all built in already, no need for custom tables, and that's how taxonomy terms are meant to be assigned - when you're in a CPT you can assign it some terms, but in the terms themselves you don't assign to a CPT.

1
  • You don't understand nor the question, nor the problem with PW. [Firstly] wp_posts and wp_postmeta is the MOST garbage tables which world databases ever have. Especially when you have CPT with 100 CustomFields. Thus I'm trying to split them and store all additional CPT Metabox CustomFields not at wp_postmeta trash, but at separate custom table like "wp_Cars". [Secondly] For this CPT which CustomFields stored at custom table I need to store many Taxonomies Terms ID's. I have 2 options: A or B. I've asking of which is better and why? Commented Aug 22, 2023 at 14:59

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.