Creating & Accessing Custom Columns in wp_posts Table


Is it possible to create custom columns in wp_posts table and then access them through out the site.

Also, some help with writing hooks that will allow me to display them as input fields on the add posts page and display then these fields on the front-end.

It would had been much easier if this was possible in CustomPress.

Thanks in advance.

  • Arun Basil Lal
    • New Recruit

    Hey Alok,

    So if I understand correctly, you want to have some fields that you want to add in the "Add New Post" editor and then want to show them on the front end using the theme right?

    CustomPress can create Custom Fields and that will do exactly the same right? i.e. Have fields in the editor, and you can display them on the front end using the embed code, don't you think?

    Let me know!

  • Alok Sharma
    • Design Lord, Child of Thor

    @Arun - To be precise, I am in the impression if the custom data is stored in wp_posts table in its own table column, then the data is pulled more quickly as compared to the wp_postmeta table. Please correct me if I am wrong.

    But going on the simpler implementation, I fully agree that CustomPress is the best solution so far.

    @Timothy - Thanks, I will read the article and try to make the best out of it.

  • Alok Sharma
    • Design Lord, Child of Thor

    Hi Arun,

    Yes, that's what I am referring to. For a low traffic site, I really wouldn't bother but for a high traffic site with millions of page views per day, this makes a lot of difference.

    As the custom data is stored in the wp_posts table in its respective table column, it is able to access the data mush faster.

    With wp_postmeta, it has to establish a relationship with wp_post, and then perform a query to find the matching record.

    I have seen this in some rating plugin that stores the votes in the wp_posts table in its own column and then also provides a hook to display these ratings anywhere in the site.

    Actually I did ask this question in the WP community but never got any reply.

    I thought there was already a solution for this.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.