I want to add two custom field to table wp_posts, and that I need for my plugin. now to enable these fields I have changed core file of wordpress
wordpress/wp-admin/post.php
$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid' ) );
here I have added two fields which I want.
Now I want these things as installable( I have manually added two fields here).
So how to do that within plugin.
I have read one post http://wp.tutsplus.com/tutorials/creative-coding/add-a-custom-column-in-posts-and-custom-post-types-admin-screen/ here hooks are used in theme function.php,but i want to do in plugin itself.
I am using wordpress 3.6.
still any confusion please comment I will update.
You should not be editing core files, it makes it very difficult to upgrade.
Use the
add_meta_box()
function and put it in a plugin file.See example below, this plugin will add a meta box to all pages in your wordpress installation. Just edit it for your own means…
In this code I am changing the columns of my edit.php page, I am basically keeping only the checkbox, author and date I am adding acf fields from the posts to the edit.php page but you can add other meta there.