WordPress.org

Ready to get started?Download WordPress

Forums

Custom PostType vs WP_List_Table (3 posts)

  1. edrdesign
    Member
    Posted 1 year ago #

    First, I apologize if this is in the wrong discussion. I am brand new to WordPress plugin development and I have a fairly general question concerning best practices:

    The website's main function will be to provide price quotes for users to view and ultimately the users can sell their products to the admins of the site based on the quoted price.

    I started writing the plugin using WP_List_table to query and display the data from the custom tables that I created with the plugin. When it came time to code the editing function WP_List_Table left me a little lost on how to either link to a custom page with fields to edit the products and their price quotes in the database or use some WordPress API.

    I then came across information on creating custom post types and now I am little confused on which route to go down: creating custom post types for the products and their price quote or hard-coding the tables, etc. with WP_List_Table.

    Any thoughts on the matter?

    In case I wasn't clear enough on how the website will function, imagine:

    1. The website's main function will be to buy video games from the users
    2. The user goes to the site and selects things like "Title", "Edition", "Condition", etc.
    2. The website then provides a price quote to the user

    All of the above needs to be accomplished using AJAX.

    Any help on which route to take will be greatly appreciated, thank you!

  2. bcworkz
    Member
    Posted 1 year ago #

    WP_List_Table is only a way to display table data and to provide links for further actions. It does not provide any editing capabilities. The action links you add to the table must be to pages that handle the actual action. This class will not do anything for you except display data and action links, the rest is up to you.

    If the data you are collecting is in custom tables, custom post types will not help much either. CPTs are still posts, just a different type. All data should still be stored in the posts and postmeta tables, not your custom tables. It's certainly possible to use CPTs with custom tables, but if you are not storing useful info in postmeta or leveraging the features of posts, such as comments and categories, what's the point?

    With custom tables, you could build your own forms to manage the data, but then why WordPress and not some generic CMS? To use WP, you should look at ways to leverage it's features as much as possible instead of blazing your own way. Maximize what CPTs can do for you by storing data in posts and postmeta. Then you can use built in functions to work with the data instead of dealing with raw mySQL queries.

    Not to say custom tables serve no purpose, they are useful when you need some powerful data crunching abilities for the underlying data. Just avoid them unless there is a good reason.

    Mind you, these are just my opinion, I'm sure you can find contradicting opinions. You're at a critical point in designing your data structure. Choose well, as changing it farther along could be difficult. Consider ways to use the existing WP structure to meet your needs. Deviate from this only for good reason.

  3. edrdesign
    Member
    Posted 1 year ago #

    Makes sense, I appreciate the input. I started over using CPTs and it seems to be more inline with what I am trying to accomplish. The interesting part will just be querying the post tables to pull ajax requests on the front end. Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic