I am trying to add an extra field in my Add Post ,
i added a field to wp_post that can be 0 or 1
and then i wanna add check box into publish box in wordpress add post or edit post
that checked when that field is 1 or unchecked when 0
and also it should can be save after submit update
I know that I can use Custom Field Templates, but the problem is that these custom fields insert the values into wp_postmeta and not wp_post, and I need everything for the single post in the same table.
actually i need to add extra field for using a query that retrieve some record that i need for converting to json and the read it not all posts, for application on android and ios
First of all, you shouldn’t modify the core table, as a lot of people already mentioned. You can do a select using join from both tables like that:
More about it here: http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query
Other than that, what exactly is your problem? To display a custom checkbox you can use add_meta_box function. To update it you need to add your function to
wp_insert_post_data
hook and then insert your data to the database, something like that:Or like that if you insist on doing it via changes to the core table:
But yeah, it’s a pretty bad way. You should use
update_post_meta
instead.we have plugin for add custom filed to the post.
https://wordpress.org/plugins/advanced-custom-fields/
1.crete a field
2.assign to post
The best solve is Relwis’s Meta Box plug-in for this. You can use it. Source link