Support » Developing with WordPress » Taxonomy or post type?

  • Resolved lluisclava

    (@lluisclava)


    Hello,

    I’m new in developing WordPress Plugins. I’m already read all the plugin handbook but I can’t find a solution about that.

    I need to develop a plugin that can create a custom table and show a page with the data of the table and a filter. I already done this part with a shortcode in a page and it’s workings good.

    The problem is, now I want to clic on every element of this table and show it’s details but with an url like wordpress.org/element/id/. And I want to respect the permlinks configuration from the site.

    How could I implement that?
    I need a custom taxonomy or a custom post type?
    How can I respon to the request /element/id/?

    Thanks so much, and sorry about English.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Can you please throw some more light what exactly you are showing in your custom table ?
    Reason why you are creating this plugin ?

    Subrata Sarkar

    (@subrataemfluence)

    First I would like to know why you need to create a custom table. WordPress table structure is awesomely robust and has the room for almost everything. If you are building a generic plugin then I would like to tell you that WordPress VIP does not allow you to create custom tables.

    If you are trying to create a special type of content, opt for Custom Post Type so that contents can easily get stored in wp_posts and wp_postmeta tables just like a regular Post.

    And you have the full control over your Custom Post Type. It will also allow you to use WordPress’s permalink structure automatically and you don’t have to do anything special for this.

    If you require a special type of taxonomy to be associated only with your Custom Post Type, just create and attach it when you are register your Custom Post Type.

    I would strongly suggest to use the database architecture WordPress has provided. I believe it is more than enough to handle almost all situations.

    Hope this helps.

    Hi Subrata Sarkar,

    First of all, thanks for your answers.

    I’m going to create a pet food filter. The data that I need to store in the table is about 80 columns. Just to don’t merge things with the post concept and because I need to load data from external source, I choosed a new table. For me, is more simple to use a custom table.

    The plugin isn’t a generic ones, is just for one website.

    Thanks.

    • This reply was modified 3 weeks, 4 days ago by  lluisclava.
    • This reply was modified 3 weeks, 4 days ago by  lluisclava.
    Moderator bcworkz

    (@bcworkz)

    The amount of data alone would not justify a custom table, it’s more related to how one might need to query for the data that dictates a custom table. OTOH, the need to import existing data could justify a custom table, though a custom import script could negate that justification.

    The problem you will have with a custom table is that hardly any of the useful WP data functions will be of much use to you. You are pretty much developing your own app when you use a custom table.

    You can use the Rewrite API to define your own permalink structure. After the permalink is rewritten into URL query vars, the query vars are available to your code through the $_GET super global. From there you can make SQL queries of your table by using the $wpdb database connection object. The results of that query can be processed and output to the browser.

    A tutorial on how all of that is accomplished is beyond the scope of these forums, but if you have specific questions regarding working your app into WordPress functionality, we will certainly try to answer.

    Hi bcworkz,

    Ok, I will review everything you say to be sure about the custom table, and I will try it on the plugin.

    Thanks so much.

    Hello,

    Finally, I used this solution. It works fine for me and I thing is the best one considering what bcworkz and Subrata Sarkar said.

    Solution

    Thanks to all.

    Sorry, this is the correct link: Solution

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.