Where can I find the file where the_content()
gets the value from post_content
in the database?
I wanted to do the concept but with another content from the database,
So far, I’ve added a new column to the database ex. post_content2
How can I get its value by using something like
<?php the_content2(); ?>
I tried looking at post-template.php
and found the function but not how it gets the value from the database post_content.
From the comments above, and a more complete answer:
Do not modify core WP tables. Either use post_meta functions, or add a new table.
the_content()
is just a convenience function that directly accesses theposts
table,content
column. You can do the same thing at any time by getting the value from the database, and passing it throughapply_filters('the_content', $my_custom_content);
. If you want to write your ownthe_content2()
function, it could / should be done like so (using thepost_meta
method mentioned above):If you want to figure out how to SAVE this content, then you can read this writeup:
How to Create Custom Meta Boxes in WordPress
edit
It’s worth noting that this functionality is already available in a few different plugins you can install. In my experience Custom Field Suite is the most reliable and easy to use (but that’s just my opinion).