Which tables need to be included with MySQL query statement?

I'm hoping to insert listings into mysql to be used by the directory plugin. I see there is a relationship between various tables that are to be involved. (terms, taxomomy, etc.).

Does anyone know which tables need be included? My goal is to abide by the WP default schema so reduce issues with other plugins or goodies.

  • Joe

    Ari hey! Well I'm sort of in research learning stage. Diving into the plugin itself more in depth is a good thought. I guess I was working from the db back. Seems the WP schema splits out things like unique ID into additional tables. (additional, being if my original non WP db kept 'unique ID' within same table as listing content).

    It's no so much how to move it, just more of how does the WP db organize itself differently than say a db conceptualized around ''red stuff table (which includes red unique ID's)" and "blue stuff tables (which include blue ID's)".

    Seems WP db schema groups 'all stuff' together regarding unique ID's. Essentially creating only one concept of unique ID through db. Has anybody tried to write a mysql query that inserts listing data into all the needed tables?

    I will jump into the directory plugin too. Sorry to post without fully exploring the plugin as that may answer some too.

    Thanks!

  • aristath

    Hello again @Joe!

    The WordPress DB has the post IDs in multiple spots...
    There's the posts table, the post_meta table, as well as the taxonomies tables!
    As I mentioned above, it would be best to avoid writing an SQL query to add these in the db.
    Instead, what I would recommend would be programmatically adding your listings via PHP.
    This way everything goes through the WordPress API, you can use sanitizations a lot easier and avoid a lot of trouble...
    Here's an example of how to do it for normal posts: https://tommcfarlin.com/programmatically-create-a-post-in-wordpress/

    All that's different between normal posts and directory listings is the post type and a couple of custom fields, so you can simply use the code on that post as an example and edit/extend it to include whatever you need.

    We can help you implement that and write the code if you need assistance... :slight_smile:

    Cheers,
    Ari.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.