Skip to main content
16 events
when toggle format what by license comment
S Jan 27, 2017 at 5:36 history bounty ended BlueDogRanch
S Jan 27, 2017 at 5:36 history notice removed BlueDogRanch
Jan 27, 2017 at 5:36 vote accept BlueDogRanch
Jan 24, 2017 at 1:42 history edited Dave Romsey
Update tags
Jan 23, 2017 at 22:27 answer added Dave Romsey timeline score: 3
Jan 23, 2017 at 22:18 comment added BlueDogRanch There is no other code; everything is above. post.php/edit is default core WordPress.
Jan 23, 2017 at 22:04 comment added CK MacLeod The answer to the first part of the new question seems obvious, but to give a full answer I think we'll need to see your code for adding the checkbox in post.php/edit.
S Jan 23, 2017 at 21:01 history bounty started BlueDogRanch
S Jan 23, 2017 at 21:01 history notice added BlueDogRanch Current answers are outdated
Jan 23, 2017 at 20:58 comment added BlueDogRanch Joel, thanks, that now works, but something else now gives me a different issue, outlined in my edit.
Jan 23, 2017 at 20:57 history edited BlueDogRanch CC BY-SA 3.0
update
Jan 20, 2017 at 16:41 comment added BlueDogRanch Thanks, I'll test this. I was about to get back to my Q, as I need this to work.
Jan 19, 2017 at 2:20 comment added Joel $_POST[$field] is an array of all the data submitted by the form. I'd simplify your code to get rid of that foreach. Then have if (isset($_POST['headline_news'])) {update_post_meta( $post_id, 'headline_news', <value if checked, which I think is 1> );} else {update_post_meta( $post_id, 'headline_news', <value if unchecked, which I think is 0> );}
Jan 8, 2017 at 21:17 comment added BlueDogRanch Thanks, I'm not clear myself what $_POST[ $field ] does anyway; the save function is cribbed from another example of using Quick Edit. I can probably delete the foreach, too, as there is only one custom field. I'm using a checkbox because I eventually need to change the save function to delete_post_meta on save if the box is unchecked; I need to query posts on the existence of the custom field, not its content, the end result being so I don't have to add that custom field to thousands of posts already in a database.
Jan 8, 2017 at 20:51 comment added Joel This is actually related to how HTML handles checkboxes in forms. If the box is checked, the $_POST['headline_news'] is populated. But if not checked, the field is not included in the posted data. That's why it doesn't get triggered. One way around this might be radio buttons. Another might be javascript to set a hidden field when the radio box is unchecked.
Jan 8, 2017 at 19:19 history asked BlueDogRanch CC BY-SA 3.0